Excel 2010 multiple find and replace macro challenge

jamesnorrisuk

New Member
Joined
Jan 11, 2013
Messages
5
Hi All,

I am looking to create a macro that will automatically find and replace a number of different values in a worksheet.

e.g. there may be 50 instances of '59df7-0bd0' that need replacing with 'James Norris', and there may be 50-odd variations to include. Any other solutions that I've seen still require user input, like using ctrl-H.

Thanks!

<colgroup><col width="64"></colgroup><tbody>
</tbody>
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Are the values you are replacing and the data that you are replacing them with on the same worksheet or do you want to be prompted to enter the replacement data manually? What do you mean by
50-odd variations
?
 
Upvote 0
Are the values you are replacing and the data that you are replacing them with on the same worksheet or do you want to be prompted to enter the replacement data manually? What do you mean by ?

The values will all be on the same worksheet. By 50-odd, I mean that I have 50 different find and replaces to undertake. The issue stems from exporting data from a program where the value is an integer, and needing to replace that integer with the display name.
 
Upvote 0
Are the display names also on the sheet or will you have to enter them manually? If they are on the sheet, which columns are they in?
 
Upvote 0
Can I assume that the values are in columns A through K?
 
Upvote 0
Try the following code. I would suggest that you create a button on your sheet and assign the macro to it.

Code:
Sub ReplaceValue()
    Dim rRange1 As Range
    Dim rRange2 As Range
    Dim name As String
    On Error Resume Next
        Application.DisplayAlerts = False
            Set rRange1 = Application.InputBox(Prompt:= _
                "Click on replacement name.", _
                    Title:="Name", Type:=8)
    On Error GoTo 0
        Application.DisplayAlerts = True
        If rRange1 Is Nothing Then
           Exit Sub
        Else
          name = rRange1.Value
        End If
        
    Application.DisplayAlerts = False
            Set rRange2 = Application.InputBox(Prompt:= _
                "Click on value to replace.", _
                    Title:="Value to replace", Type:=8)
    On Error GoTo 0
        Application.DisplayAlerts = True
        If rRange2 Is Nothing Then
           Exit Sub
        Else
          rRange2.Value = rRange1.Value
        End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,136
Members
448,551
Latest member
Sienna de Souza

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