Okay, this makes a few assumptions.
- Root folder will always be in following format: mmyy (0604,0704,0804)
- The root month determines what the new files will be named
To use, run the UpdateFileMonth procedure. It will prompt for your prior month's file. Select the correct folder, and it will process.
Be careful though, there is no error checking for user input errors. Make sure that you select the correct folder before processing.
<font face=Courier New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Type</SPAN> BrowseInfo
hWndOwner <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
pidlRoot <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
sDisplayName <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
sTitle <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
ulFlags <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
lpfn <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
lParam <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
iImage <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Type</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Declare</SPAN> <SPAN style="color:#00007F">Function</SPAN> SHBrowseForFolder <SPAN style="color:#00007F">Lib</SPAN> "Shell32.dll" (bBrowse <SPAN style="color:#00007F">As</SPAN> BrowseInfo) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Declare</SPAN> <SPAN style="color:#00007F">Function</SPAN> SHGetPathFromIDList <SPAN style="color:#00007F">Lib</SPAN> "Shell32.dll" (<SPAN style="color:#00007F">ByVal</SPAN> lItem <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, <SPAN style="color:#00007F">ByVal</SPAN> sDir <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">Sub</SPAN> UpdateFileMonth()
<SPAN style="color:#00007F">Dim</SPAN> oldFolder <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, newFolder <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
oldFolder = BrowseForDirectory("Select Prior Month Folder")
<SPAN style="color:#00007F">If</SPAN> oldFolder <> vbNullString <SPAN style="color:#00007F">Then</SPAN>
RollFiles oldFolder, Right(oldFolder, 4)
MsgBox "Complete!"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> RollFiles(filePath <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, replaceValue <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>)
<SPAN style="color:#00007F">Dim</SPAN> fso <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>, fld <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>, subfld <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>, f <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
<SPAN style="color:#00007F">Set</SPAN> fso = CreateObject("Scripting.FileSystemObject")
<SPAN style="color:#00007F">Set</SPAN> fld = fso.GetFolder(filePath)
<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
MkDir AddDate(fld.Path, replaceValue)
<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> f <SPAN style="color:#00007F">In</SPAN> fld.Files
FileCopy f.Path, AddDate(f.Path, replaceValue)
<SPAN style="color:#00007F">Next</SPAN>
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> subfld <SPAN style="color:#00007F">In</SPAN> fld.SubFolders
RollFiles subfld.Path, replaceValue
<SPAN style="color:#00007F">Next</SPAN>
<SPAN style="color:#00007F">Set</SPAN> fld = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> fso = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Function</SPAN> AddDate(value <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, searchFor <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> tmp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, tmpReplace <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> tmpDate <SPAN style="color:#00007F">As</SPAN> Date
tmp = value
tmpDate = DateValue(Left(searchFor, 2) & "/1/" & Right(searchFor, 2))
tmpDate = DateAdd("m", 1, tmpDate)
tmpReplace = Format(tmpDate, "mmyy")
tmp = Replace(tmp, searchFor, tmpReplace)
AddDate = tmp
tmp = vbNullString
tmpReplace = vbNull<SPAN style="color:#00007F">String</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Function</SPAN> BrowseForDirectory(<SPAN style="color:#00007F">Optional</SPAN> title <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> browse_info <SPAN style="color:#00007F">As</SPAN> BrowseInfo
<SPAN style="color:#00007F">Dim</SPAN> item <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> dir_name <SPAN style="color:#00007F">As</SPAN> String
<SPAN style="color:#00007F">With</SPAN> browse_info
.pidlRoot = 0
.sDisplayName = Space$(260)
.sTitle = title
.ulFlags = 1
.lpfn = 0
.lParam = 0
.iImage = 0
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
item = SHBrowseForFolder(browse_info)
<SPAN style="color:#00007F">If</SPAN> item <SPAN style="color:#00007F">Then</SPAN>
dir_name = Space$(260)
<SPAN style="color:#00007F">If</SPAN> SHGetPathFromIDList(item, dir_name) <SPAN style="color:#00007F">Then</SPAN>
BrowseForDirectory = Left(dir_name, _
InStr(dir_name, Chr$(0)) - 1)
<SPAN style="color:#00007F">Else</SPAN>
BrowseForDirectory = ""
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN>
</FONT>
This code should be placed in a standard module.