“dd/mm/yyyy” date format in excel through vba

后端 未结 2 859
忘了有多久
忘了有多久 2021-01-12 07:34

I am trying to write a date in \"dd/mm/yyyy\" format in excel sheet thru excel-vba. I achieved it using Cells(1, 1).Value = Format(StartDate, \"dd/mm/yyyy\"). a

相关标签:
2条回答
  • 2021-01-12 08:15

    Your issue is with attempting to change your month by adding 1. 1 in date serials in Excel is equal to 1 day. Try changing your month by using the following:

    NewDate = Format(DateAdd("m",1,StartDate),"dd/mm/yyyy")
    
    0 讨论(0)
  • 2021-01-12 08:19

    I got it

    Cells(1, 1).Value = StartDate
    Cells(1, 1).NumberFormat = "dd/mm/yyyy"

    Basically, I need to set the cell format, instead of setting the date.

    0 讨论(0)
提交回复
热议问题