Can anyone help with this please:
I wish to Find any cells in Rows(1) with the value "To Attribs". Then for each column with this heading, for each cell, to replace specific strings with "" (i.e. delete the strings).
In case it is relevant, some of the cells in the columns with the "To Attribs" heading are empty.
This is the code I have so far, but it only acts on one of the columns with "To Attribs" in Rows(1) and the Loop doesn't seem to be working:
I wish to Find any cells in Rows(1) with the value "To Attribs". Then for each column with this heading, for each cell, to replace specific strings with "" (i.e. delete the strings).
In case it is relevant, some of the cells in the columns with the "To Attribs" heading are empty.
This is the code I have so far, but it only acts on one of the columns with "To Attribs" in Rows(1) and the Loop doesn't seem to be working:
Code:
Dim titRng As Range
Dim TargetStr20 As String
Set titRng = ActiveWorkbook.Sheets(1).Rows(1)
TargetStr20 = "To Attribs"
Set foundCell20 = titRng.Find(what:=TargetStr20, LookIn:=xlValues, _
lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=True, SearchFormat:=False)
k = ""
If Not foundCell20 Is Nothing Then
Do Until foundCell20 Is Nothing
Set ToRng20 = Intersect(foundCell20.EntireColumn, ws1.UsedRange)
ToRng20.Replace what:=MyString1, replacement:=k, lookat:=xlPart, MatchCase:=True
ToRng20.Replace what:=MyString3, replacement:=k, lookat:=xlPart, MatchCase:=True
ToRng20.Replace what:=MyString4, replacement:=k, lookat:=xlPart, MatchCase:=True
foundCell20.Value = "Replaced"
Set foundCell20 = titRng.FindNext
Loop
Else
End If