user1283776
user1283776

Reputation: 21784

Date format conforming to regional settings, but also including weekday

I know that if I set the numberformat "m/d/yyyy" using VBA, then that numberformat will adapt to the user regional settings. Some countries will see 3/12/2015 while others will see 2015-03-12.

Is there a way set a numberformat that includes both date and weekday, such as "dddd m/d/yyyy" and have this conform to regional settings as well?

Upvotes: 1

Views: 126

Answers (1)

You can start by setting NumberFormat to plain "m/d/yyyy" so it adapts to regional settings. Then read NumberFormatLocal to see what the actual resulting format is. Then prepend "dddd " to that.

Dim r As Range
Set r = Range("A1")
r.NumberFormat = "m/d/yyyy"
r.NumberFormatLocal = "dddd " & r.NumberFormatLocal

For example, with my regional settings, I get this:

enter image description here

Upvotes: 2

Related Questions