Bạn thử đoạn code này nhé:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer, j As Integer
Dim Cll(1 To 30000) As Variant
If Target.Address = "$C$1" Then
Range("C1:C65536").ClearContents
For i = 2 To 30000
If Cells(i, 1).Value <> "" And Cells(i, 1).Interior.ColorIndex = xlNone Then
j = j + 1
Cll(j) = Cells(i, 1).Value
End If
Next i
For i = 1 To j
Cells(i + 1, 3).Value = Cll(i)
Next i
End If
End Sub
Khi chọn ô C1 trên sheet2, sẽ lọc ra cho bạn những ô không màu.
File đính kèm:
View attachment 69057