VBA to replace multiple strings.

kizmet311

New Member
Joined
Sep 7, 2018
Messages
8
I have an excel file with several strings of text that I need to replace. The "Find" strings are all in the same column. So I need find in column C and replace with value's stored in the VBA, back into column C.

FindReplace
ASSISTANT COACH - CLASSIFIEDOther
ASSISTANT COACH - PARAOther
ASSISTANT COACH-XDUTYOther
BUS AIDE - EXCEPTIONAL CHILDTransportation Staff
BUS DRIVER TRAINING ASSISTANTTransportation Staff
BUS DRIVER TRNING COORDINATORTransportation Staff
SUB BUS DRIVERTransportation Staff
BUS MONITORTransportation Staff
CERTIFIED SOCIAL WORKERTeacher/Professional
CERTIFIED STAFFTeacher/Professional
CHIEF INFORMATION OFFICERTechnology Staff
CHILD DEVELOP CENTER ASST SUPROther
CHILD DEVELOPMENT CENTER SUPRVOther
COMPUTER ENGINEERTechnology Staff
COMPUTER LAB TECHNICIANTechnology Staff
COOK/BAKERCafeteria Staff
COORDINATOR IOther
CUSTODIAL SUPERVISORFacilities Staff
SUB CUSTODIANFacilities Staff
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Assuming you have a sheet named "Find-Replace" with the strings to find in column A and the replacement string in column B then you can use this code when the sheet with text to be replaced is the ActiveSheet.

VBA Code:
Sub t()
Dim c As Range, sh As Worksheet
Set sh = ActiveSheet
    With Sheets("Find-Replace")
        For Each c In .Range("A1", .Cells(Rows.Count, 1).End(xlUp))
            Columns(3).Replace c.Value, c.Offset(, 1).Value
        Next
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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