Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Date: End of last month as YYMM

Hello,
I am looking for a good way to capture the YYMM of the last month as a
string.
My macro runs a monthly process and I would like it to automatically save to
monthly directory labeled by the year and month. If I were to run it today,
24-May-2007 I would like the result to be YYMM = "0704".

Could someone suggest a way to do this in VBA without relying on computing
on a worksheet?

Thanks in advance,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default End of last month as YYMM

I am looking for a good way to capture the YYMM of the last month
as a string.
My macro runs a monthly process and I would like it to automatically
save to monthly directory labeled by the year and month. If I were to
run it today, 24-May-2007 I would like the result to be YYMM = "0704".


Did you really mean the "last month" as in the one previous May? Assuming
you did...

YourMonth = #24-May-2007#
PreviousMonth = Format$(DateAdd("m",-1,YourDate), "yymm")

Rick

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default End of last month as YYMM

You get that date like so

Format(Date - Day(Date),"YYMM")

to automatically create the directory use

MkDir Format(Date - Day(Date),"YYMM")

but wrap error handling around it in case it already exists

On Error Resume Next
MkDir Format(Date - Day(Date),"YYMM")
On error Goto 0


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bythsx-Addagio" wrote in message
...
Hello,
I am looking for a good way to capture the YYMM of the last month as a
string.
My macro runs a monthly process and I would like it to automatically save
to
monthly directory labeled by the year and month. If I were to run it
today,
24-May-2007 I would like the result to be YYMM = "0704".

Could someone suggest a way to do this in VBA without relying on computing
on a worksheet?

Thanks in advance,



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 formating yymm sconstance Excel Discussion (Misc queries) 2 April 4th 08 05:07 PM
Date arithmetic: adding 1 month to prior end of month date manxman Excel Worksheet Functions 2 July 14th 06 09:29 PM
Sort month/date/year data using month and date only SMW820 Excel Discussion (Misc queries) 6 June 22nd 06 05:14 PM
Determine begin month date from month end date. mikeburg[_59_] Excel Programming 3 January 13th 06 08:42 PM
Saving file in the format "YYMM" Dolphinv4 Excel Discussion (Misc queries) 2 October 5th 05 12:08 PM


All times are GMT +1. The time now is 07:45 AM.

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

About Us

"It's about Microsoft Excel"