office交流網(wǎng)--QQ交流群號及微信交流群

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

微信交流群(請用微信掃碼)

        

VBA判斷Excel單元格的數(shù)據(jù)類型

2020-04-23 08:00:00
zstmtony
原創(chuàng)
3614

VBA判斷Excel單元格的數(shù)據(jù)類型


Public Function gf_CheckCellType(cel As Range) As String

    Dim strType As String



    Select Case True

    Case Application.IsText(cel)

        strType = "文本"

    Case Application.IsLogical(cel)

        strType = "邏輯值"

    Case IsEmpty(cel)

        strType = "空值"

    Case IsNumeric(cel)

        strType = "數(shù)值"

    Case Application.IsErr(cel)

        strType = "錯誤值"

    Case IsDate(cel)

        strType = "日期"

    End Select

    MsgBox "[" & cel.Address & "] 的數(shù)據(jù)類型爲:" & strType

    gf_CheckCellType = strType

End Function


分享
聯(lián)繫我們
聯(lián)繫人: 王先生
Email: 18449932@qq.com
QQ: 18449932
微博: officecn01
移動訪問