Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date value conditional formatting or Macro Wanna Learn Excel Discussion (Misc queries) 0 July 22nd 08 01:01 PM
Date Formatting in a Macro [email protected] Excel Discussion (Misc queries) 3 May 19th 06 02:09 AM
formatting date-time values in macro scw-tzg Excel Worksheet Functions 2 November 14th 05 09:21 PM
Macro drops date formatting to csv file bslater Excel Programming 1 October 23rd 03 08:00 PM
Formatting Date Macro Sarah[_4_] Excel Programming 4 October 15th 03 03:12 PM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"