ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Month plus one (https://www.excelbanter.com/excel-programming/360149-month-plus-one.html)

ew

Month plus one
 
I have a code that I would like the code to look for the format of the file
path and the file name plus one month. So that today (April) it would be
looking for the file with name May. Example:

"G:\CC folder\Accounts\grape juice\LA Sheets\Concord " & Format(Date,
"mmm-yyyy") & ".xls"

Thanks for any help in advance!

martin

Month plus one
 
Dim PathName as String
Dim NewDate as Date

PathName = "G:\CC folder\Accounts\grape juice\LA Sheets\Concord "
NewDate = DateSerial(Year(Date),Month(Date)+1,1)
' NewDate is the first of next month; otherwise if we put 'Day(Date)'
instead of '1'
' then the code would blow up on January 30, March 31, etc.
PathName = PathName & Format(NewDate, "mmmm") & ".xls"



All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com