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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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