Macro to Find and Replace Cell References

TooZippy

Board Regular
Joined
Dec 30, 2018
Messages
70
I used this macro and it works to a certain extent. At first, I was having it look for "$M", "$N", "$O", “$P”, “$Q”, “$R”, “$S”,“$T”, “$U”. These cell references are the result after deleting a few columns in another spreadsheet. They are t be replaced with "$Q", "$R", "$S", “$T”, “$U”, “$V”, “$W”,“$X”, “$Y” (in that order) in a range of formulas off to the right.

It did not work since I had "$Q", "$R", "$S", “$T”, “$U” in both the Find and Replace. I took that out and it worked except that the order of the cell references in the formulas was mixed up. I need to have $Y cell reference at the far right of the formulas because I have a sum formula adding up the columns to the left of this column. Can anybody help please?

Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Sub Find_and_Replace()[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000] [/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Dim Rng As Range[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Dim InputRng As Range, ReplaceRng As Range[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]xTitleId = "KutoolsforExcel"[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Set InputRng = Application.Selection[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Set InputRng = Application.InputBox("Formulas to Fix ",xTitleId, InputRng.Address, Type:=8)[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Set ReplaceRng = Application.InputBox("Find and Replace Values:", xTitleId, Type:=8)[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Application.ScreenUpdating = False[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]For Each Rng In ReplaceRng.Columns(1).Cells[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]    [/COLOR][COLOR=#000000]InputRng.Replacewhat:=Rng.Value, replacement:=Rng.Offset(0, 1).Value[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Next[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]Application.ScreenUpdating = True[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][COLOR=#000000]End Sub[/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT]

Thank you,

Jared Z.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Here is a table of what I am trying to find and replace along with the results with the above formula. Can anybody help please?

Thank you,

Jared Z.

FindReplaceResult
$I$Q$UCol. 1
$J$R$VCol. 2
$k$S$WCol. 3
$L$T$XCol. 4
$M$U$YCol. 5
$N$V$RCol. 6
$O$W$SCol. 7
$P$X$TCol. 8
$Q$Y$UCol. 9

<colgroup><col width="64" style="width:48pt" span="4"> </colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

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