vizgraphics
New Member
- Joined
- Jun 8, 2016
- Messages
- 6
Hello,
I have a large chunk of text that I need to find and replace a bunch of different values within. I have one file with columns for the find and replace values. I'm setting up a text box in a separate file that I will paste the large chunk of text to search through. I need the macro to open the external file, look through all the rows for anything in Column Q and replace with Column R. Here's where I'm at but I can't get the text to replace in the box:
Any help would be appreciated
I have a large chunk of text that I need to find and replace a bunch of different values within. I have one file with columns for the find and replace values. I'm setting up a text box in a separate file that I will paste the large chunk of text to search through. I need the macro to open the external file, look through all the rows for anything in Column Q and replace with Column R. Here's where I'm at but I can't get the text to replace in the box:
Code:
Sub ConvertJobNumbers() Dim NameListWB As Workbook, thisWb As Workbook
Dim NameListWS As Worksheet, thisWs As Worksheet
Dim i As Long, lRow As Long
Dim shp As Object
'This is the workbook from where your code is running
Set thisWb = ThisWorkbook
'This is the Sheet we are looking at to replace text in
Set thisWs = thisWb.Sheets("Sheet1")
'Open external file to find and replace from
Set NameListWB = Workbooks.Open("jobMapping.xlsx")
Set NameListWS = NameListWB.Worksheets("Sheet1")
With NameListWS
'Look for textboxes and other shapes
For Each shp In thisWs.Shapes
'Do the replace
If shp.Name = "TextBox 1" Then
shp.TextFrame.Characters.Text.Replace What:=.Range("Q" & i).Value, _
Replacement:=.Range("R" & i).Value, _
SearchOrder:=xlByColumns, _
MatchCase:=False
End If
Next shp
End With
End Sub
Any help would be appreciated