Try next code and check, check, check.
Has been remove the space after the comma when 2 sheets where mentioned (Sheet1,Sheet2) to avoid confusion with the space inside the sheet's name
Option Explicit
Sub ReplaceData()
Dim ObjDic As Object
Dim WkRg As Range
Dim F As Range
Dim G
Dim WkSh As Worksheet
Dim WkStg1 As String, WkStg2 As String
Dim WkSet
Dim I As Integer
Dim AAA, BBB, CCC
Application.ScreenUpdating = False
Set ObjDic = CreateObject("Scripting.Dictionary")
With Sheets("Code Sheet")
For Each F In Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
If (F.Value <> "") Then ObjDic(F.Value) = F.Offset(0, 1).Value
Next F
For Each F In Range(.Range("E2"), .Range("E" & Rows.Count).End(xlUp))
If (F.Value <> "") Then
If (F.Value = "All") Then
For Each WkSh In Worksheets
If (WkSh.Name <> "Code Sheet") Then
For Each G In ObjDic.keys
WkStg1 = G
Call FindReplace(WkStg1, ObjDic(G), WkSh.Name)
Next G
End If
Next WkSh
Else
WkSet = Split(F.Value, ",")
For I = 0 To UBound(WkSet, 1)
For Each G In ObjDic.keys
WkStg1 = G: WkStg2 = WkSet(I)
Call FindReplace(WkStg1, ObjDic(G), WkStg2)
Next G
Next I
End If
End If
Next F
End With
Application.ScreenUpdating = True
End Sub
Sub FindReplace(StgOrg As String, StgDest As String, WkSh As String)
With Sheets(WkSh).Cells
.Replace What:=StgOrg, Replacement:=StgDest, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
End With
End Sub
Bookmarks