Capitalizing the first letter of a formatted date

eirikdaude

Board Regular
Joined
Nov 26, 2013
Messages
93
Office Version
  1. 365
Platform
  1. Windows
I want to use VBA to capitalize the first letter of a formatted date. To give an example, when I put

VBA Code:
? format(#1/1/2023#, "Ddd", vbMonday, vbFirstFourDays)

into the immediate window, I want it to output "Sø.", but what I get is "sø.". In a perfect world I'd want it to be a three-letter truncation instead of having the period at the end, but that's not as much of a deal as the first letter being lowercase.

Whether format or some other function is used for the task doesn't matter, but I don't want to need an intermediary step, ideally.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
And as I post the thread, I remember about StrConv...

VBA Code:
? strconv(format(#1/1/2023#, "Ddd", vbMonday, vbFirstFourDays), vbProperCase)

does what I want, but if someone has a more elegant way of doing this please let me know! :p
 
Upvote 0
Elegant enough. But to retrieve the 3 leading chars, maybe use:

VBA Code:
? Left(strconv(format(#1/1/2023#, "dddd", vbMonday, vbFirstFourDays), vbProperCase),3)
 
Upvote 0
Solution

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top