我有一个包含三个工作表的工作簿
如何在主表单栏T中创建所有值的唯一列表并将其放在仪表板表格中(从A6开始)?
答案 0 :(得分:1)
尝试一下:
Sub dural()
Dim w1 As Worksheet, w2 As Worksheet
Dim N As Long, i As Long, col As Collection
Dim j As Long
Set w1 = Sheets("Master")
Set w2 = Sheets("Dashboard")
N = w1.Cells(Rows.Count, "T").End(xlUp).Row
Set col = New Collection
For i = 1 To N
v = w1.Cells(i, "T").Value
cv = CStr(v)
On Error Resume Next
col.Add v, cv
If Err.Number = 0 Then
w2.Range("A6").Offset(j, 0).Value = w1.Cells(i, "T")
j = j + 1
Else
Err.Number = 0
On Error GoTo 0
End If
Next i
End Sub