+ Reply to Thread
Results 1 to 8 of 8

Loop through Column and add hyperlink

  1. #1
    Smythe32@aol.com
    Guest

    Loop through Column and add hyperlink

    Hi,

    I am terribly bad with loops and was hoping someone could help me with
    some code.

    I have column A, called Item. It has numbers in it.


    ex:
    Item
    123
    124
    234
    223

    I need to loop through all the non blank cells in the column and add a
    hyperlink to each item number. They hyperlink would be something like
    http:....123. The ticket number would be at the end. The main part of
    the hyperlink excluding the ticket number is always the same.

    Thanks for anyone who can assist.


  2. #2
    Smythe32@aol.com
    Guest

    Re: Loop through Column and add hyperlink

    The ticket number would be at the end. The main part of
    the hyperlink excluding the ticket number is always the same.


    Correction:

    The item number would be at the end. The main part of
    the hyperlink excluding the item number is always the same.


  3. #3
    Steve
    Guest

    Re: Loop through Column and add hyperlink

    This will start looking at column A, row 2 and stops when it reaches the
    first blank cell in column A.
    The hyperlink is written into column B.

    Sub HlinkPaths()
    Dim i
    Dim tmp
    Dim myUrl
    i = 2
    myUrl = "http://www.google.com/" 'replace with your URL

    While Range("A" & i).Value + "" <> ""
    tmp = myUrl & Range("A" & i).Value

    ActiveSheet.Hyperlinks.Add _
    Anchor:=Range("A" & i).Offset(, 1), _
    Address:=tmp, _
    TextToDisplay:=tmp
    i = i + 1
    Wend

    End Sub


    <Smythe32@aol.com> wrote in message
    news:1133929155.410840.177900@g47g2000cwa.googlegroups.com...
    > The ticket number would be at the end. The main part of
    > the hyperlink excluding the ticket number is always the same.
    >
    >
    > Correction:
    >
    > The item number would be at the end. The main part of
    > the hyperlink excluding the item number is always the same.
    >




  4. #4
    Dave Peterson
    Guest

    Re: Loop through Column and add hyperlink

    I'd just use another column of cells and the =hyperlink() worksheet function:

    =hyperlink("http://www.whatever.com/" & a2,"Click me")

    or something like this.

    Smythe32@aol.com wrote:
    >
    > Hi,
    >
    > I am terribly bad with loops and was hoping someone could help me with
    > some code.
    >
    > I have column A, called Item. It has numbers in it.
    >
    > ex:
    > Item
    > 123
    > 124
    > 234
    > 223
    >
    > I need to loop through all the non blank cells in the column and add a
    > hyperlink to each item number. They hyperlink would be something like
    > http:....123. The ticket number would be at the end. The main part of
    > the hyperlink excluding the ticket number is always the same.
    >
    > Thanks for anyone who can assist.


    --

    Dave Peterson

  5. #5
    Smythe32@aol.com
    Guest

    Re: Loop through Column and add hyperlink

    Thank you very much. This helped a great deal.


  6. #6
    Smythe32@aol.com
    Guest

    Re: Loop through Column and add hyperlink

    Thank you, this worked perfect.


  7. #7
    Smythe32@aol.com
    Guest

    Re: Loop through Column and add hyperlink

    yes, that would make sense from the question I asked. There was
    actually another part that I left out. When you drill down into a pivot
    table and a new sheet is created, I was putting this code in the
    newsheet event because it loses the hyperlinks otherwise. Thanks for
    you idea too..


  8. #8
    Registered User
    Join Date
    04-13-2011
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Loop through Column and add hyperlink

    How would this be modified for numbers in column "A" instead of text?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1