如果A1有内容 – 运行macroA否则什么都不做…?
我有一个button签名到macros,但是如果单元格A1
没有内容,我得到debugging错误(通过运行)
我想知道,如标题所说..我可以运行一个macros的IF命令?
所以,如果Sheet1!A1 = ANY content
( THEN run macroA
不同), THEN run macroA
IF Sheet1!A1 = no content THEN do nothing
(button只是没有做什么)
可能?
请尝试:
Sub Macro1() If WorksheetFunction.CountA(Range("A1")) = 0 Then MsgBox "A1 is empty" Else Application.Run "Macro2()" 'edit macro name to suit End If End Sub
不是do nothing
– 显示为什么没有(多)发生的警告。 但是,如果你愿意,可以注释掉MsgBox行。