Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dede
 
Posts: n/a
Default Find and Replace Hyperlink Contents

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"?

  #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
  #3   Report Post  
Dede
 
Posts: n/a
Default

How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.

"Dave Peterson" wrote:

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

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Take a look at David's notes:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Dede wrote:

How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.

"Dave Peterson" wrote:

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


--

Dave Peterson
  #5   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi Dede,

see Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote ...
How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.





  #6   Report Post  
Dede
 
Posts: n/a
Default

First of all, thanks for all the help!

I added the code and it ran but nothing changed. I am wondering about the
"old" and "new" path statements. My hyperlink is not an "http" link; mine
links to a file on a network server. My hyperlink starts off with "file:///"
I am only wanting to change the portion of the hyperlink that contains the
word "iis" to "iis2" so in my code I put for the OldStr = "iis" and the
NewStr = "iis2". Is that correct? After I ran the code, the path still
displays "iis" in the hyperlink.

"David McRitchie" wrote:

Hi Dede,

see Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote ...
How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.




  #7   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi Dede,
I think your substitutions in the code look correct.

The macro will only change the hyperlink, what you see with
insert hyperlink (ctrl+k), it is not set up to change the cell
value (text value). If you change the hyp.TextToDisplay
you will wipe out formulas, so was not included.

BTW, I would include periods and slashes immediately next
to your old and new strings to reduce possibiliy of collateral damage
to other portions of your links, including inadvertent use in the wrong
workbook.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote in message ...
First of all, thanks for all the help!

I added the code and it ran but nothing changed. I am wondering about the
"old" and "new" path statements. My hyperlink is not an "http" link; mine
links to a file on a network server. My hyperlink starts off with "file:///"
I am only wanting to change the portion of the hyperlink that contains the
word "iis" to "iis2" so in my code I put for the OldStr = "iis" and the
NewStr = "iis2". Is that correct? After I ran the code, the path still
displays "iis" in the hyperlink.

"David McRitchie" wrote:

Hi Dede,

see Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote ...
How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.







  #8   Report Post  
Dede
 
Posts: n/a
Default

Thanks David,

I changed the code again and added the slashes but the hyperlink still does
not change when I run the macro.

I don't want the text value of the cell to change, just the hyperlink. Any
idea what I am doing wrong?

"David McRitchie" wrote:

Hi Dede,
I think your substitutions in the code look correct.

The macro will only change the hyperlink, what you see with
insert hyperlink (ctrl+k), it is not set up to change the cell
value (text value). If you change the hyp.TextToDisplay
you will wipe out formulas, so was not included.

BTW, I would include periods and slashes immediately next
to your old and new strings to reduce possibiliy of collateral damage
to other portions of your links, including inadvertent use in the wrong
workbook.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote in message ...
First of all, thanks for all the help!

I added the code and it ran but nothing changed. I am wondering about the
"old" and "new" path statements. My hyperlink is not an "http" link; mine
links to a file on a network server. My hyperlink starts off with "file:///"
I am only wanting to change the portion of the hyperlink that contains the
word "iis" to "iis2" so in my code I put for the OldStr = "iis" and the
NewStr = "iis2". Is that correct? After I ran the code, the path still
displays "iis" in the hyperlink.

"David McRitchie" wrote:

Hi Dede,

see Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote ...
How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.







  #9   Report Post  
Dave Peterson
 
Posts: n/a
Default

You may want to post your code.

Dede wrote:

Thanks David,

I changed the code again and added the slashes but the hyperlink still does
not change when I run the macro.

I don't want the text value of the cell to change, just the hyperlink. Any
idea what I am doing wrong?

"David McRitchie" wrote:

Hi Dede,
I think your substitutions in the code look correct.

The macro will only change the hyperlink, what you see with
insert hyperlink (ctrl+k), it is not set up to change the cell
value (text value). If you change the hyp.TextToDisplay
you will wipe out formulas, so was not included.

BTW, I would include periods and slashes immediately next
to your old and new strings to reduce possibiliy of collateral damage
to other portions of your links, including inadvertent use in the wrong
workbook.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote in message ...
First of all, thanks for all the help!

I added the code and it ran but nothing changed. I am wondering about the
"old" and "new" path statements. My hyperlink is not an "http" link; mine
links to a file on a network server. My hyperlink starts off with "file:///"
I am only wanting to change the portion of the hyperlink that contains the
word "iis" to "iis2" so in my code I put for the OldStr = "iis" and the
NewStr = "iis2". Is that correct? After I ran the code, the path still
displays "iis" in the hyperlink.

"David McRitchie" wrote:

Hi Dede,

see Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Dede" wrote ...
How do I go about putting this code in? I was trying to use Find and Replace
from the menu. I am not familiar with inserting code.








--

Dave Peterson
  #10   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi Dede,
and what you see with Ctrl+K (insert hyperlink) for the
Type the file or Web page name:
Text to display:
ScreenTip: (if not empty)
also what you see on the formula bar if not the same as Text to display

The slashes or periods added would not make it work if it is not working
-- that suggestion was just to prevent you from making inadvertent changes.

To make sure you installed in correct place include this line of code
Msgbox "installed correctly, now what?"
You should be running as standalone from Alt+F8 to invoke macro
and there should only be one macro with that name shown.

Can't imagine that you would have anything in the following, unless you
inherited the workbook, but check anyway.
file, properties, summary, hyperlink base:

http://www.mvps.org/dmcritchie/excel...#FixHyperlinks


"Dave Peterson" wrote ...
You may want to post your code.

Dede wrote:
I changed the code again and added the slashes but the hyperlink still does
not change when I run the macro.







  #11   Report Post  
Dede
 
Posts: n/a
Default

I am starting to think maybe I have my code in the wrong place. When I open
the sheet and do Alt+F11. I double-click on "This Workbook" on the left hand
side. This opened a window that has a drop-down for "General" and "Workbook"
and I tried running the code in both places.

Am I putting the code in the wrong place?

"David McRitchie" wrote:

Hi Dede,
and what you see with Ctrl+K (insert hyperlink) for the
Type the file or Web page name:
Text to display:
ScreenTip: (if not empty)
also what you see on the formula bar if not the same as Text to display

The slashes or periods added would not make it work if it is not working
-- that suggestion was just to prevent you from making inadvertent changes.

To make sure you installed in correct place include this line of code
Msgbox "installed correctly, now what?"
You should be running as standalone from Alt+F8 to invoke macro
and there should only be one macro with that name shown.

Can't imagine that you would have anything in the following, unless you
inherited the workbook, but check anyway.
file, properties, summary, hyperlink base:

http://www.mvps.org/dmcritchie/excel...#FixHyperlinks


"Dave Peterson" wrote ...
You may want to post your code.

Dede wrote:
I changed the code again and added the slashes but the hyperlink still does
not change when I run the macro.






  #12   Report Post  
Dave Peterson
 
Posts: n/a
Default

Actually, the code belongs in a General module.

Select your project in the VBE's project explorer.
Then Insert|module.
Then paste there.

But if you actually ran that code (F5 or Run|Run Sub from within the VBE), it
should have worked ok.

How did you run the code (well, if you did run the code)?

And if it still doesn't work, you still may want to paste your code. (Remember
that you have to match case or code around it.)


Dede wrote:

I am starting to think maybe I have my code in the wrong place. When I open
the sheet and do Alt+F11. I double-click on "This Workbook" on the left hand
side. This opened a window that has a drop-down for "General" and "Workbook"
and I tried running the code in both places.

Am I putting the code in the wrong place?

"David McRitchie" wrote:

Hi Dede,
and what you see with Ctrl+K (insert hyperlink) for the
Type the file or Web page name:
Text to display:
ScreenTip: (if not empty)
also what you see on the formula bar if not the same as Text to display

The slashes or periods added would not make it work if it is not working
-- that suggestion was just to prevent you from making inadvertent changes.

To make sure you installed in correct place include this line of code
Msgbox "installed correctly, now what?"
You should be running as standalone from Alt+F8 to invoke macro
and there should only be one macro with that name shown.

Can't imagine that you would have anything in the following, unless you
inherited the workbook, but check anyway.
file, properties, summary, hyperlink base:

http://www.mvps.org/dmcritchie/excel...#FixHyperlinks


"Dave Peterson" wrote ...
You may want to post your code.

Dede wrote:
I changed the code again and added the slashes but the hyperlink still does
not change when I run the macro.







--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and REPLACE within a selection, or column- not entire sheet/. smithers2002 Excel Worksheet Functions 4 April 21st 05 04:45 PM
Find and Replace - Quickest Option? Lindsey M Excel Worksheet Functions 1 March 8th 05 11:34 AM
Can I use Find and Replace all with Hyperlinks? HandsOnManager Excel Discussion (Misc queries) 0 February 15th 05 07:39 PM
find replace cursor default to find box luffa Excel Discussion (Misc queries) 0 February 3rd 05 12:11 AM
VB Find and Replace Bony_Pony Excel Worksheet Functions 10 December 6th 04 05:45 PM


All times are GMT +1. The time now is 04:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"