直接上代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MST As String
Select Case True
Case Application.IsText(Target)
MST = "文本"
Case Application.IsLogical(Target)
MST = "逻辑值"
Case IsEmpty(Target)
MST = "空值"
Case IsNumeric(Target)
MST = "数值"
Case Application.IsErr(Target)
MST = "错误值"
Case IsDate(Target)
MST = "日期"
End Select
MsgBox MST
End Sub
其实就是监测SelectionChange事件。然后用对应的检测方法去检测就好了。