I am using the guidance here: Find and replace in a loop using macro in Excel
I have a workbook "TLA Lookup.xlsx" saved in a shared location. It has a sheet named TLAs. Column A consists of a list of TLAs and column B is the corresponding business name.
I have a macro to check the TLA Lookup workbook and wherever the TLA exists, replace it with the business name. I can do this within the same workbook.
I have different workbooks where I want this find/replace to happen. I have to copy the TLAs sheet from the TLA Lookups workbook over every time. I want to reference that workbook automatically instead.
How do I reference the TLA Lookup as being the workbook the macro needs to look in for the find/replace text?
Sub find_replace_2()
Dim TLA As String
Dim NAME As String
Dim i As Long
Dim wb As Workbook
Dim sht1 As Worksheet
'Open the Workbook that has all of the TLAs and CI Names from the K drive,
' so now both workbooks are open
Workbooks.Open Filename:= _
"K:\CLE01\Team_QA\Upcoming Change Highlights\TLA Lookup.xlsx"
Set wb = TLA Lookup.xlsx ' <---- Here is where I get a syntax error
Set sht1 = wb.Sheets("TLAs")
For i = 1 To 4000
TLA = wb.sht1.Range("A" & i).Value
NAME = wb.sht1.Range("B" & i).Value
Selection.Replace What:=TLA, replacement:=NAME _
, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat _
:=False, ReplaceFormat:=False
Next i
End Sub