Date Format Macro

petes

Board Regular
Joined
Sep 12, 2009
Messages
168
Friends -

I need a macro that will display the curret date in message box in the belwo format:

09_03_2014


Thanks a lot!!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You could use:
Code:
Sub ShowDate()
msgbox format(date, "mm_dd_yyyy")
end sub
 
Upvote 0
If your regional settings are US, see post #4.

PS This being an Excel board, people will assume you want VBA since VBS has nothing to do with Excel. ;)
 
Upvote 0
You said that today() was not a vba method. My bad. But it is an excel function. So just call that function into a variable and split it.
Today = application.worksheetfunction.today()

Or use this...
Today = Format(Date.Now(), "mm/dd/yyyy")

Then the rest of the code...
var = split(Today,"/")
Output = var(0) & "_" & var(1) & "_" & var(2)
Msgbox Output
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,560
Latest member
Torchwood72

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