Afternoon all -
I've written some vba code to save the workbook with the current month:
ActiveWorkbook.SaveAs Filename:= _
"P:\filename" & Format(Date, " mmm") & ".xls"
which works fine - brings back filename MAY
How can I tweak this code to make it bring back the previous month, i.e. APR?
Any help much appreciated.
Cheers
Steve
Last edited by SAsplin; 05-17-2011 at 08:59 AM.
Hi,
Try:
ActiveWorkbook.SaveAs Filename:= _ "P:\filename" & Format(DateSerial(Year(Date), Month(Date), 0), " mmm") & ".xls"
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Hi Dom
Thanks for the post. It now highlights DateSerial and comes back with a 'compile error':
Argument not optional.
Steve
Works fine for me. Have you copied the code I posted exactly?
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Thanks Marco,
Works great. User error as always!!
Steve
Marco's not here![]()
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Brilliant. I can't even remember names! Thanks Dom!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks