Results 1 to 3 of 3

Thread: [RESOLVED] Macro to create Hyperlink basing from cell address value

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Resolved [RESOLVED] Macro to create Hyperlink basing from cell address value

    Hi,

    I've looked in most threads related to creating macro for hyperlinks but i couldn't find one that can answer to my queries. Below is my problem.

    I have two sheets, 1st sheet is a calendar, which contains Months and days. the 2nd sheet is only having 1 column with "Locate Date" as heading. Each of the rows within that column has values like L16, B25, B19, D9, D4, E10 etc.

    i want to create a macro that will go through each of these values, and will create hyperlink with respect to sheet 1. For example, if in Sheet 2, cell1 has L16 value, then i want to make a hyperlink on cell1 which reference it's value to that in Sheet 1. Thus, when hyperlink is made, when i click on cell 1, it will go to Sheet 1 with address L16.

    The original spreadsheet i have has hundreds of values in "Locate Date" column. It would take time for me to manually create a hyperlink in Excel if i have to do it one by one.

    Please help me with this. I'd really appreciate your help. Attached is my sample workbook.
    Attached Files Attached Files

  2. #2
    Hyperactive Member
    Join Date
    Dec 2000
    Location
    Sydney
    Posts
    311

    Re: Macro to create Hyperlink basing from cell address value

    Hi

    Try this:

    vb Code:
    1. Dim i As Integer
    2.    
    3.     i = 4
    4.     For i = 4 To 10
    5.         Range("A" & i).Select
    6.         ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="Sheet1!" & Range("A" & i).Text, TextToDisplay:=Range("A" & i).Text
    7.     Next i

    That will start at cell A4, as you've already done A3 and finish at A10. Amend it as required for your real spreadsheet.

    Cheers
    Why do today what you can tomorrow...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Thumbs up Re: Macro to create Hyperlink basing from cell address value

    Quote Originally Posted by Help321 View Post
    Hi

    Try this:

    vb Code:
    1. Dim i As Integer
    2.    
    3.     i = 4
    4.     For i = 4 To 10
    5.         Range("A" & i).Select
    6.         ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="Sheet1!" & Range("A" & i).Text, TextToDisplay:=Range("A" & i).Text
    7.     Next i

    That will start at cell A4, as you've already done A3 and finish at A10. Amend it as required for your real spreadsheet.

    Cheers
    Thanks a lot :-) This is what i really need. I tried to use the same concept but the one thing i couldn't do is how to implement it in ActiveSheet.Hyperlinks.Add method. I kind of confused what to put in "SubAddress" as i am getting an invalid link in my previous code.

    Thank you so much again for the help :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width