Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Filename in VBA
Workbooks.Open Filename:="R:\Daily Revenue Report\Daily
Revenue\THKL-DRR.xls" Sheets("report").Select ActiveSheet.Unprotect Windows("drr0107.XLS").Activate From the code above, every month a new "drrmmyy.xls" file will be created (where mm = month & yy = year). What codes do I need to write so that the macro will automatically use the new filename to replace the previous month, i.e. in feb-07 the new file will be drr0207 and this will replace the drr0107 file in the code above? Greatly appreciate any and all forms of assistance rendered! Thanx very much :-) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Filename in VBA
Assuming the file is made within the month it represents:
Dim sFileName as String sFileName = "drr" & Format(Now, "mmyy") & ".XLS" - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "SuperLC" wrote in message ... Workbooks.Open Filename:="R:\Daily Revenue Report\Daily Revenue\THKL-DRR.xls" Sheets("report").Select ActiveSheet.Unprotect Windows("drr0107.XLS").Activate From the code above, every month a new "drrmmyy.xls" file will be created (where mm = month & yy = year). What codes do I need to write so that the macro will automatically use the new filename to replace the previous month, i.e. in feb-07 the new file will be drr0207 and this will replace the drr0107 file in the code above? Greatly appreciate any and all forms of assistance rendered! Thanx very much :-) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
changing the filename in a Link | Excel Discussion (Misc queries) | |||
PivotTables and Changing the FileName | Excel Programming | |||
Changing filename | Excel Programming | |||
Changing Filename when linked to other worksheets | Excel Discussion (Misc queries) | |||
hyperlinks-changing the filename only! | Excel Programming |