cell format

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I've set a column of cells to be formatted as mm/dd/yyyy,
however when i move the date value of one of these cells
to a string variable, the value in the variable is
displayed as my regional option for the short date which
is mmddyy. Is there a way around this. Can you set the
regional system options with VBA and then reset when the
spreadsheet application is closed?

Thanks,
Mike
 
Dim sStr as String
sStr = Range("A1").Text

Demoing from the immediate window:

range("A1").Value = Date
range("A1").NumberFormat = "mmmm dd, yyyy"
? range("A1").Value
1/3/04
? range("A1").Text
January 03, 2004
sStr = range("A1").Text
? sStr
January 03, 2004
 
Back
Top