edit replace with vba using referenced cell text

Zeppelin9

New Member
Joined
Jul 15, 2016
Messages
2
The given selection of cells contains all links to another file. The file name has the word "May" in it. I want to be able to update all these links each month from month to month and just edit, replace with the month names. The following code works to update all the links from May to June, but I want to put a couple dropdowns in the file and let the user select a "prior month" and "current month" and have the following code reference the text in those two cells instead of having the months hard-coded in the below code. Seems simple, but I've tried a couple things and am stumped. Any help would be great!

Range("F5:Q150").Select
Selection.Replace What:="May", Replacement:="June", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Must of just missed something the first couple times... got it... super simple:

Dim CurrentCloseMonth As String
Dim PriorCloseMonth As String

CurrentCloseMonth = Sheets("Parameters").Range("B2").Value
PriorCloseMonth = Sheets("Parameters").Range("B4").Value

Range("F5:Q150").Select
Selection.Replace What:=PriorCloseMonth, Replacement:=CurrentCloseMonth, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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