VBA单击单元格触发事件
(2019-03-16 19:32:37)
标签:
活力星语金钟常鸣vba |
分类: VBA |
打开excel-开发工具-Visual Basic-双击Sheet1(sheet1)-在右侧的代码区输入:
'如何在单击某个区域的单元格时判断该单元是否为空
'如果为空时,数值为所在列数
'如果不为空则输入空值
Target.Value =
"=Column()" '单元格变为所在列的列数
Target.Value
= ""
If Target.Value
= "" Then '如果单元格为空
Target.Value = "=Column()"
'单元格变为所在列的列数
Else
Target.Value = ""
End If
'如果为空时,数值为所在列数
'如果不为空则输入空值
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
''类似单击事件
If Target.Value = "" Then '如果单元格为空
Else
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
If Not Application.Intersect([B1:F12], Target) Is Nothing Then
'仅在B1:F12范围内起作用
End If
End Sub
后一篇:VB在OLE中打开文件

加载中…