dnicholsby
New Member
- Joined
- Jan 24, 2017
- Messages
- 26
Hello,
I have 6 keywords that I would like to cycle through with the following code but I can't seem to get it to work. Any ideas?
I have 6 keywords that I would like to cycle through with the following code but I can't seem to get it to work. Any ideas?
Code:
Sub ChangeLinks()
Dim wb As Workbook
Set wb = Application.ActiveWorkbook
Dim Path As String
Path = Application.ActiveWorkbook.Path
Dim NewName As String
Dim KeyWord As Variant
For Each link In wb.LinkSources(xlExcelLinks)
If InStr(link, KeyWord) Then
For Each cl In Sheets("Start Here").Range("b6:b12")
If cl.Value = KeyWord Then
NewName = Path & "\" & cl.Offset(0, -1).Value
wb.ChangeLink Name:=link, NewName:=NewName, Type:=xlExcelLinks
End If
Next cl
Next KeyWord
End If
Next link
End Sub