IF A1有内容 - 运行macroA否则什么也不做? [英] IF A1 has content - run macroA Else do nothing ...?

查看:131
本文介绍了IF A1有内容 - 运行macroA否则什么也不做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道,正如标题所示..我可以运行一个带有宏的IF命令吗?



所以,如果 Sheet1!A1 =任何内容(不同时间)然后运行宏A



IF Sheet1!A1 =没有内容THEN do nothing (按钮什么都不做)



可能? >

解决方案

请尝试:

  Sub Macro1()
如果WorksheetFunction.CountA(范围(A1))= 0然后
MsgBoxA1为空
Else
应用程序。运行Macro2()'编辑宏名称以适应
如果
End Sub

不完全不做任何事情 - 显示为什么没有(很多)发生的警告。如果您愿意,请注释掉MsgBox行。


I have a button signed to a Macro, However if cell A1 has no content I get the debug error (runs via that)

I was wondering, as title says.. Can I run a IF command with a Macro?

So, If Sheet1!A1 = ANY content (differs from time to time) THEN run macroA

IF Sheet1!A1 = no content THEN do nothing (button just does nothing)

Possible?

解决方案

Please try:

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  

Not quite do nothing - displays a warning of why nothing (much) happened. But comment out the MsgBox line if you prefer.

这篇关于IF A1有内容 - 运行macroA否则什么也不做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆