Reputation: 165
I want to assign a macro to a button, but the code run in that condition when any cell is selected in a Range of ActiveSheet("A:A")
. Otherwise it prompt me a msg box "cell is not selected".
Upvotes: 0
Views: 1067
Reputation: 165
This code is also works for me:
Sub PrintPreview()
If Intersect(ActiveCell, Range("A:A")) Is Nothing Then
MsgBox "No cell is selected"
Else
'write code here
End If
End Sub
Upvotes: 1
Reputation: 14373
If ActiveCell.Column = 1 Then
' Do your stuff
Else
MsgBox "No cell is selected"
End If
Upvotes: 2