Replace formula's file

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
Hi all, i would like to write a Vba, so that to run through col. "C", "D", "E", "F" and where find the formulas which contains the file OCCUPANCY 2017, should replace it with OCCUPANCY 2018 but with Input Box in which i will write the file.

Thanking you in advance
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You can use the find/replace that excel has.
select eh range of cells, hit Ctrl & H
Find what "OCCUPANCY 2017", replace with what "OCCUPANCY 2018", you may have to go into options and have formulas selected.

If it works and you still want a code for doing that, then use the macro recorder.
 
Upvote 0
Thank you dave. It works your above command and is an effective idea. Just i prefer an "Input Box" so that to write by manual method the file which i will replace. If i recorder the above, it will be a stable command. I need to change the file any time. Is it possible the above, to record it using "Input Box" ? I would be greatly appreciate if you could help me. Thanks once again!
 
Last edited:
Upvote 0
Below is the code. I recorded as you explain me but i prefer the replacement option to be valid through "Input Box". Thanks

Range("C9:L252").Select
Cells.Replace What:="OCCUPANCY", Replacement:="OCCUPANCY 2018", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 
Upvote 0
This should do it
Code:
    Dim fnd As String
    Dim rplc As String
    fnd = InputBox("Find what?")
    rplc = InputBox("Replace with?")

    Range("C:L").Replace what:=fnd, Replacement:=rplc, LookAt:=xlPart, _
                             SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
                             ReplaceFormat:=False
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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