View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

For hyperlinks that were inserted via Insert|Hyperlink?

If yes, then visit David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/buildtoc.htm
look for:
Fix Hyperlinks (#FixHyperlinks)

Actually, here's David's code:

Sub Fix192Hyperlinks()
Dim OldStr As String, NewStr As String
OldStr = "http://192.168.15.5/"
NewStr = "http://hank.home.on.ca/"
Dim hyp As Hyperlink
For Each hyp In ActiveSheet.Hyperlinks
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
Next hyp
End Sub

'To make it run against all worksheets, run this macro:

sub DoItAll()
dim Wks as worksheet
for each wks in activeworkbook.worksheets
wks.select
call Fix192Hyperlinks
next wks
end sub

====
This line:
hyp.Address = Replace(hyp.Address, OldStr, NewStr)
uses Replace which was added in xl2k.

If you're using xl97, then change that line to:
hyp.Address = application.substitute(hyp.Address, OldStr, NewStr)

And both Replace and application.substitute are case sensitive.

If you have mixed case, maybe something like:
hyp.Address = Replace(ucase(hyp.Address), ucase(OldStr), NewStr)
(or application.substitute for xl97.)






Dede wrote:

How can I do a Find for all hyperlinks in my spreadsheet (or the entire
workbook) that contain "iis" in they hyperlink and Replace that portion
of they hyperlink with "iis2"?


--

Dave Peterson