在某个范围内select一个单元格时,通过button运行一个macros
我想给一个button分配一个macros,但是当在一个ActiveSheet("A:A")
范围ActiveSheet("A:A")
select了任何单元格时,代码将以该条件运行。 否则,它提示我一个味精框“细胞没有被选中”。
If ActiveCell.Column = 1 Then ' Do your stuff Else MsgBox "No cell is selected" End If
这个代码也适用于我:
Sub PrintPreview() If Intersect(ActiveCell, Range("A:A")) Is Nothing Then MsgBox "No cell is selected" Else 'write code here End If End Sub