PDA

View Full Version : Format isn't working



next
04-18-2012, 08:40 AM
I don't understand why it isn't working
Sub test()
Dim sheet As Worksheet
Dim today As Date

today = Format(Now, "mm-dd")
Debug.Print today

For Each sheet In ActiveWorkbook.Sheets
'Debug.Print sheet.Name
Next sheet

End Sub

Shouldn't the output be 04-18? Instead I'm getting 4/18/2012. What am I missing here?

Tinbendr
04-18-2012, 09:33 AM
When I change the object from Date to Variant or String, I get the correct output.

BrianMH
04-18-2012, 10:43 AM
Yeah that makes since the format function returns a string not a date.