Macro to change filename in another macro

BBRed

New Member
Joined
Oct 23, 2015
Messages
2
Hi,
I have a macro that opens a file, selects columns, copies and pastes on another file, saves file, then closes both files. I have to run this Marco every month. The way I run it every month is I go into the macro and find and replace the date with the new date. For example: C:My Documents: Asset Schedule 0815 needs to change to C:My Documents: Asset Schedule 0915. So what I do is I go into the VBA code and Find 0815 and Replace it with 0915. So my question is, instead of doing this manually, can I make another Marco that will change my filename in my original Macro? It would be really nice if I can change it using a cell reference so if my cell says 0915 it will change all the file names using that reference. Thanks in advance!!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
what if you replaced
"C:My Documents: Asset Schedule 0815"
with
"C:My Documents: Asset Schedule " & Right("0" & Month(Date), 2) & Right(Year(Date), 2)
Or
"C:My Documents: Asset Schedule " & "Sheets("Sheet1").range("B2").value
 
Last edited:
Upvote 0
This could definitely work but I tried option 2 and it keeps highlighting "sheet1" It's on sheet 1.
 
Upvote 0
Er line 2 has an extra quote.. More like:

"C:My Documents: Asset Schedule " & Sheets("Sheet1").range("B2").value

Otherwise you could look into named ranges and do something like range("YourRangeName").value
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top