VBA code to set date format for a specific column as “yyyy-mm-dd”

后端 未结 3 810
太阳男子
太阳男子 2020-12-15 05:40

I have a macro which I specify the date (in mm/dd/yyyy) in a textbox and I want to set this value for column A in yyyy-mm-dd format. I have the following code:



        
3条回答
  •  情歌与酒
    2020-12-15 06:25

    It works, when you use both lines:

    Application.ActiveWorkbook.Worksheets("data").Range("C1", "C20000") = Format(Date, "yyyy-mm-dd")
    Application.ActiveWorkbook.Worksheets("data").Range("C1", "C20000").NumberFormat = "yyyy-mm-dd"
    

提交回复
热议问题