如何把excel应用在一个单元格的宏,变成对一列的每个单元格都生效呢?
Subtest()Application.DisplayAlerts=FalseOnErrorGoToendlineSetd=CreateObject("scriptin...
Sub test()
Application.DisplayAlerts = False
On Error GoTo endline
Set d = CreateObject("scripting.dictionary")
Set x = Application.InputBox("", "选择单元格", , , , , , 8)
If x.Count > 1 Then MsgBox "只能选择单个单元格!": GoTo endline
If Len(x) = 0 Then MsgBox "所选为空值!": GoTo endline
Set y = Application.InputBox("", "选择放置结果的区域", , , , , , 8)
arr = VBA.Split(x, ",")
For Each Rng In arr
d(Rng) = ""
Next
Range(y.Address)(1).Range("a1") = VBA.Join(d.keys, ";")
d.RemoveAll
endline:
Application.DisplayAlerts = True
End Sub 展开
Application.DisplayAlerts = False
On Error GoTo endline
Set d = CreateObject("scripting.dictionary")
Set x = Application.InputBox("", "选择单元格", , , , , , 8)
If x.Count > 1 Then MsgBox "只能选择单个单元格!": GoTo endline
If Len(x) = 0 Then MsgBox "所选为空值!": GoTo endline
Set y = Application.InputBox("", "选择放置结果的区域", , , , , , 8)
arr = VBA.Split(x, ",")
For Each Rng In arr
d(Rng) = ""
Next
Range(y.Address)(1).Range("a1") = VBA.Join(d.keys, ";")
d.RemoveAll
endline:
Application.DisplayAlerts = True
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询