Dave Nilges
Dave Nilges

Reputation: 23

Excel VBA - Text to Date after running macro in a single Row

I have several Macros running at once in a file. The output pastes unique dates from B1:Z1 on the next sheet. The dates right now are pasting as ex. 43619 instead of 6/3/2019. I have been troubleshooting this but everything I have found is a whole column instead of rows. Thanks!

Upvotes: 0

Views: 26

Answers (1)

Scott Craner
Scott Craner

Reputation: 152605

To Excel a Date is a number(the number of days since 1/1/1900). The number is formatted to look like a date.

If you are just pasting the values the format is not following and as such the value is reverted to the number.

To apply the formatting just use:

Worksheet("Sheet1").Range("B1:Z1").NumberFormat = "mm/dd/yyyy"

Changing the sheet name to your desired sheet and the number format to the format desired.

Upvotes: 1

Related Questions