Thread: Date Format
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Date Format

The "m", "d", and "y" meta-characters only work if the value (first
argument) is a *real* date value... your strTest is a String value. You
could do this...

strTest = Format(CDate(strTest), "mm-dd-yy")

but I am wondering why you went through the intermediate step of assigning
Date to a variable in the first place, just use it directly...

strTest = Format(Date, "mm-dd-yy")

--
Rick (MVP - Excel)


"Ken Hudson" wrote in message
...
I have the following code as part of a macro:

Dim strTest As String
strTest = Date
strTest = Format(strTest, "mm-dd-yy")

When I compile the code I get the following error:

Compile error:

Wrong number of arguments or invalid property assignment.

I am getting a headache staring at this and trying to figure out the
obvious
error, but can't.


--
Ken Hudson