EXCEL循环内先判断是否为空,再存入字典VBA
A列查找且去重复值并把结果显示到G列假如数据源A列有空行时程序如何修改求大神解决,谢谢Subtest()Application.ScreenUpdating=FalseD...
A列查找且去重复值 并把结果显示到G列 假如数据源A列有空行时 程序如何修改 求大神解决, 谢谢
Sub test()
Application.ScreenUpdating = False
Dim name()
Set dic = CreateObject("Scripting.Dictionary")
a = [a65536].End(xlUp).Row
For Each Cell In Worksheets("扣明细").Range("a2:a" & a)
If Not dic.exists(Cell.Value) Then
dic.Add Cell.Value, Cell.Value
On Error Resume Next
End If
Next
name = dic.items
For i = 1 To dic.Count
Worksheets("扣明细").Cells(i + 1, 7) = name(i - 1)
Next
End Sub
A列空行不要删除的情况下 展开
Sub test()
Application.ScreenUpdating = False
Dim name()
Set dic = CreateObject("Scripting.Dictionary")
a = [a65536].End(xlUp).Row
For Each Cell In Worksheets("扣明细").Range("a2:a" & a)
If Not dic.exists(Cell.Value) Then
dic.Add Cell.Value, Cell.Value
On Error Resume Next
End If
Next
name = dic.items
For i = 1 To dic.Count
Worksheets("扣明细").Cells(i + 1, 7) = name(i - 1)
Next
End Sub
A列空行不要删除的情况下 展开
展开全部
Sub test()
Application.ScreenUpdating = False
Dim name()
Set dic = CreateObject("正晌Scripting.Dictionary")
a = [a65536].End(xlUp).Row
For Each Cell In Worksheets("扣明细").Range("a2:a" & a)
If Not dic.exists(Cell.Value) 迅清滚and cell.value<>亩余"" Then
dic.Add Cell.Value, Cell.Value
On Error Resume Next
End If
Next
name = dic.items
For i = 1 To dic.Count
Worksheets("扣明细").Cells(i + 1, 7) = name(i - 1)
Next
End Sub
追问
如果A列中有小计这两个字符如何跳过
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询