Date Format Macro

petes

Board Regular
Joined
Sep 12, 2009
Messages
164
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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

petes

Board Regular
Joined
Sep 12, 2009
Messages
164
Today is not recognised in VB Script....Any other alternative??

Thanks
 
Upvote 0

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
40,383
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
You could use:
Code:
Sub ShowDate()
msgbox format(date, "mm_dd_yyyy")
end sub
 
Upvote 0

petes

Board Regular
Joined
Sep 12, 2009
Messages
164
Guys I need this in VB script...

Only these formats are recognized by VB Script (Refer below URL)

VBScript Functions
 
Upvote 0

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
40,383
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
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

WarPigl3t

Well-known Member
Joined
May 25, 2014
Messages
1,611
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,191,216
Messages
5,985,318
Members
439,956
Latest member
venky2002

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
Top