Find and Replace Macro Not Working

TooZippy

Board Regular
Joined
Dec 30, 2018
Messages
70
This macro was posted in MrExcel some time ago and I found it on the internet in a search. I tried running it but it doesn't work. Any suggestions please?

Thank you,

Jared Z.

Code:
Sub Find_and_Replace()

Dim myList, myRange
    Set myList = Sheets("Run Macros").Range("F1:G13") 'two column range where find/replace pairs are
    Set myRange = Sheets("Run Macros").Range("J2:R11") 'range to be searched
    For Each cel In myList.Columns(1).Cells
        myRange.Replace what:=cel.Value, replacement:=cel.Offset(0, 1).Value
    Next cel
End Sub
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

TooZippy

Board Regular
Joined
Dec 30, 2018
Messages
70
I click "Run" after I select the macro and the values that I want to change in range J2:R11 remain the same. The "Find values are in column "F" and the replace values are in column "G".

Thank you,

JZ
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
Are you trying to do an exact match, or a partial match?
Also does it need to be case sensitive?
Finally, are the values you are trying to change, hard values or the result of a formula?
 

TooZippy

Board Regular
Joined
Dec 30, 2018
Messages
70

ADVERTISEMENT

I ran the macro again today and it seems that it is working. However, in the first column (let's say it has a cell reference to column "I") I want to replace that reference with column "Q". It replaces that reference. When it get's to the ninth column, it may already be a reference to column "Q" so that when it changes that reference to column "Y" it will change the first column reference to column "Y" even though it should be a reference to column "Q". Is there a way around this?

Thank you,

Jared Z.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
I've absolutely no idea because I don't know what you are trying to do. ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,331
Messages
5,528,056
Members
409,799
Latest member
camronmartin

This Week's Hot Topics

Top