Need help with changing multiple file paths to UNC paths

Mikedjr15

New Member
Joined
Apr 8, 2016
Messages
4
I am planning on implementing a new files server in the upcoming weeks. A few people that we support have excel spreadsheets that have multiple drives and file paths hyperlinks and I want to change those links into there UNC paths. Then this will allow me to then just replace the old server path with the new one. I am having trouble with an efficient macro to convert multiple drives and file path to the UNC path. I did try a find and replace macro but I still found myself entering each path in the find and replace macro and it does not seem efficient. Below is my macro and the paths are just examples. Also, its for Excel 2013.

Sub Multi_FindReplace()

Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
Dim hLink As Hyperlink

fndList = Array("Z:\Football", "Z:\Basketball", "S:\Baseball")
rplcList = Array("\\ed1\new\Football", "\\ed1\new\Basketball", "\\ed1\new\Baseball")

'Loop through each item in Array lists
For x = LBound(fndList) To UBound(fndList)
'Loop through each worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht

Next x

For Each wSheet In Worksheets
For Each hLink In wSheet.Hyperlinks
hLink.Address = Replace(hLink.Address, "\\ed1\", "\\ed2\") 'Swap OldServer and NewServer to match name case sensitive
Next hLink
Next
For Each ws In Worksheets
ws.Cells.Replace What:="\\ed1\", Replacement:="\\ed2\", LookAt:=xlPart, MatchCase:=False 'Swap OldServer and NewServer to match name.
Next
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top