Results 1 to 6 of 6

Thread: How to edit multiple hyperlinks of Excel at a single time

  1. #1
    Join Date
    Feb 2012
    Posts
    13

    How to edit multiple hyperlinks of Excel at a single time

    I have a spread sheet with over 270 hyperlinks, have had to move the spreadsheet and associated links to a new location but the hyperlinks are still looking in the old location! Does anyone know a way to edit the hyperlinks 'on mass' as opposed to me editing each link individually.

  2. #2
    Join Date
    Aug 2011
    Posts
    695

    Re: How to edit multiple hyperlinks of Excel at a single time

    Try this:
    Code:
    Sub ReplaceHyperlinksInActiveWorkbook()
    Dim oSheet As Object
    Dim H As Hyperlink
    Dim stFind As String
    Dim stReplace As String
    stFind = InputBox("What is the initial path to replace?", , "\\Old\")
    If stFind = "" Then Exit Sub
    stReplace = InputBox("What should the path become?", , "\\New\")
    If stReplace = "" Then Exit Sub
    For Each oSheet In ActiveWorkbook.Sheets
    For Each H In oSheet.Hyperlinks
    If InStr(H.Address, stFind) = 1 Then
    H.Address = stReplace & Mid(H.Address, Len(stFind) + 1)
    End If
    Next
    Next
    End Sub

  3. #3
    Join Date
    Aug 2011
    Posts
    566

    Re: How to edit multiple hyperlinks of Excel at a single time

    I created a VBA routine with this, Bill, and then assigned it to a button. It is not working for me. the routine runs correctly, but the hyperlinks aren't updating. The files are on our business network, so I am wondering if that has anything to do with it.

  4. #4
    Join Date
    Jul 2011
    Posts
    623

    Re: How to edit multiple hyperlinks of Excel at a single time

    Presumably the stFind you specified is not matching the start of the hyperlink addresses you wanted to change. Could be a case-sensitivity issue. Try: If InStr(LCase(H.Address), LCase(stFind)) = 1 Then. If that still doesn't do it, get it to tell you what the Address is that it is finding:
    Code:
    For Each H In oSheet.Hyperlinks
    Debug.Print H.Address
    If InStr(LCase(H.Address), LCase(stFind)) = 1 Then
    H.Address = stReplace & Mid(H.Address, Len(stFind) + 1)
    End If
    Next

  5. #5
    Join Date
    Jul 2011
    Posts
    634

    Re: How to edit multiple hyperlinks of Excel at a single time

    No great secret. The language is Visual Basic for Applications (VBA). A good book to try for starters would be Excel NNNN Visual Basic for Applications Step by Step.

  6. #6
    Join Date
    Jul 2011
    Posts
    640

    Re: How to edit multiple hyperlinks of Excel at a single time

    Excel does not provide help for mass edits of hyperlink addresses. You will either have to use a macro similar to the one I posted on each workbook whose hyperlinks you need to change, or you could email me at Bill underscore Manville at Compuserve dot com for a free copy of LinkManager, a utility which will do this and more.
    • To run the macro is quite simple;
    • Start Excel
    • File > New
    • Alt+F11 to the visual basic editor
    • Insert > Module
    • Paste the code into the big white space that appears
    • Alt+F11 back to Excel
    • Open the workbook containing the links
    • Tools > Macro > Macros > (select the only macro) > Run

Similar Threads

  1. How to select multiple text box at a time in Microsoft Excel
    By DEvOTeEL in forum MS Office Support
    Replies: 2
    Last Post: 23-02-2012, 04:59 PM
  2. Is it possible to edit hyperlinks via vba in Excel
    By !Jumala! in forum MS Office Support
    Replies: 2
    Last Post: 23-02-2012, 12:07 PM
  3. Replies: 2
    Last Post: 17-02-2012, 01:00 PM
  4. Replies: 3
    Last Post: 25-01-2012, 12:12 PM
  5. Replies: 8
    Last Post: 04-12-2011, 11:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,564,728.52683 seconds with 17 queries