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. |
All times are GMT +1. The time now is 10:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com