Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting a date in a macro
lastmonth = Format(DateSerial(year(now()),Month(now())-1,1),"mmm")
LastMonth = lastmonth = Format(DateSerial(year(now()),Month(now())-1,1),"mmmyy") -- Regards, Tom Ogilvy "Tony" wrote in message ... I created a macro for a report I do at work and it works great, but I am trying to set a variable for the date. I use a line like < Lastmonth = Month(now()) -1 and it shows the number "8" for August which is correct. The problem is when I try to format it to say "Aug". I used < Lastmonth = Format (Month(now()) -1, "mmm") and the output I get is "Jan". Ideally I need the year also but I tried < Lastmonth = Format (Month(now()) -1, "mmmyy") and the output is "Jan00". If anyone has any suggestions I would really appreciate it. Thank you. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date value conditional formatting or Macro | Excel Discussion (Misc queries) | |||
Date Formatting in a Macro | Excel Discussion (Misc queries) | |||
formatting date-time values in macro | Excel Worksheet Functions | |||
Macro drops date formatting to csv file | Excel Programming | |||
Formatting Date Macro | Excel Programming |