Zain_inout
New Member
- Joined
- Sep 8, 2021
- Messages
- 18
- Office Version
- 2019
- Platform
- Windows
Hi,
I need to perform same tasks on different workbooks every month. The files are present at different locations. I would like to create a macro file which will open the workbook from the folder that I define and then the very first thing it will do is rename the file by just replacing the last few characters. So every time, the file name will have "0_Original" in the end and the macro will replace it with "1_RetireeCheck" and save the file at the same folder defined earlier and then run the steps that I will define in the code. Below is the code I have written till now:
Sub EEBalanceSummary()
On Error Resume Next
Dim FilePath As String
dim wb as workbook
FilePath = Application.GetOpenFilename
if not FilePath = "False" then set wb = Application.workbooks.open(Filepath)
if wb is nothing then exit sub
with wb
.Activate
.Activesheet.Range("B6").Select
end with
End Sub
Right now, there is nothing about the renaming the file. It would be great if someone can help me with that and also make sure that the renamed file is open and active and I my vba codes will work on that renamed file(the one that ends with "1_RetireeCheck")
I need to perform same tasks on different workbooks every month. The files are present at different locations. I would like to create a macro file which will open the workbook from the folder that I define and then the very first thing it will do is rename the file by just replacing the last few characters. So every time, the file name will have "0_Original" in the end and the macro will replace it with "1_RetireeCheck" and save the file at the same folder defined earlier and then run the steps that I will define in the code. Below is the code I have written till now:
Sub EEBalanceSummary()
On Error Resume Next
Dim FilePath As String
dim wb as workbook
FilePath = Application.GetOpenFilename
if not FilePath = "False" then set wb = Application.workbooks.open(Filepath)
if wb is nothing then exit sub
with wb
.Activate
.Activesheet.Range("B6").Select
end with
End Sub
Right now, there is nothing about the renaming the file. It would be great if someone can help me with that and also make sure that the renamed file is open and active and I my vba codes will work on that renamed file(the one that ends with "1_RetireeCheck")