我想为按钮分配宏,但是当在ActiveSheet("A:A")
范围内选择任何单元格时,代码将以该条件运行。否则它会提示我一个msg框"未选择单元格"。
答案 0 :(得分:2)
If ActiveCell.Column = 1 Then
' Do your stuff
Else
MsgBox "No cell is selected"
End If
答案 1 :(得分:1)
此代码也适用于我:
Sub PrintPreview()
If Intersect(ActiveCell, Range("A:A")) Is Nothing Then
MsgBox "No cell is selected"
Else
'write code here
End If
End Sub