用VBA判断excel单元格的数据类型

Sub 判断单元格数据类型()

Dim MST As String

Dim X As Integer

For X = 1 To 7

Select Case True

Case Application.IsText(Cells(X, 1))

MST = “文本”

Case Application.IsLogical(Cells(X, 1))

MST = “逻辑值”

Case IsEmpty(Cells(X, 1))

MST = “空值”

Case IsNumeric(Cells(X, 1))

MST = “数值”

Case Application.IsErr(Cells(X, 1))

MST = “错误值”

Case IsDate(Cells(X, 1))

MST = “日期”

End Select

MsgBox Cells(X, 1).Address & “的数据类型为:” & MST

Next X

End Sub

posted @ 2014-07-27 10:57  OS.cn  阅读(2675)  评论(0编辑  收藏  举报