Làm sao để ghép các số không trùng lặp

Liên hệ QC
Đây là bài tập về vòng lặp đó mà!

PHP:
Option Explicit
Sub Ghep2So()
 Dim Cls0 As Range, Cls1 As Range
 
 Range([b3], [B999].End(xlUp)).ClearContents
 For Each Cls0 In Range([A3], [a999].End(xlUp))
   For Each Cls1 In Range(Cls0.Offset(1), [a999].End(xlUp))
      If Cls1.Value <> Cls0.Value And Cls0.Address <> [a999].End(xlUp).Address Then
         [B999].End(xlUp).Offset(1).Value = Cls0.Value & "-" & Cls1.Value
      End If
   Next Cls1
 Next Cls0
End Sub


PHP:
Sub Ghep3So()
 Dim Cls0 As Range, Cls1 As Range, Cls2 As Range
 Const GN As String = "-"
 
 Range([c3], [c999].End(xlUp)).ClearContents
 For Each Cls0 In Range([A3], [a999].End(xlUp))
   For Each Cls1 In Range(Cls0.Offset(1), [a999].End(xlUp))
      For Each Cls2 In Range(Cls1.Offset(1), [a999].End(xlUp))
      
         If Cls0.Address <> [a999].End(xlUp).Address And Cls1.Address <> [a999].End(xlUp).Address Then
            [c999].End(xlUp).Offset(1).Value = Cls0.Value & GN & Cls1.Value & GN & Cls2.Value
         End If
   
   Next Cls2, Cls1
 Next Cls0
End Sub

(Chừa lại fần cuối để bạn hay ai đó thử sức xem sao)
 
bạn ơi up cho mình file hoàn chỉnh lên đi mình đang cần mà
 
Nó là [C1] í

--=0 --=0 --=0
 

File đính kèm

Web KT

Bài viết mới nhất

Back
Top Bottom