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

Access培訓(xùn)群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

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

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

        

VBA 設(shè)置單元格隻能輸入日期類型的數(shù)據(jù)

2020-05-02 08:00:00
zstmtony
原創(chuàng)
4857
VBA 設(shè)置單元格隻能輸入日期類型的數(shù)據(jù)

Sub 設(shè)置選擇區(qū)域必鬚輸入日期()
    Range("A2:A20000").Select
    Selection.NumberFormatLocal = "yyyy-mm-dd"
    With Selection.Validation
        .Delete
        .Add Type:=xlValidateDate, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="1/1/1980", Formula2:="12/31/2900"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = "請輸入入庫日期"
        .ErrorTitle = "齣錯瞭"
        .InputMessage = ""
        .ErrorMessage = "請輸入正確的日期"
        .IMEMode = xlIMEModeNoControl
        .ShowInput = True
        .ShowError = True
    End With
End Sub
分享
文章分類
聯(lián)繫我們
聯(lián)繫人: 王先生
Email: 18449932@qq.com
QQ: 18449932
微博: officecn01
移動訪問