+ Reply to Thread
Results 1 to 8 of 8

How to create auto increment hyperlinks in excel?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Chennai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    How to create auto increment hyperlinks in excel?

    Hello I'm a beginner in using excel.

    My objective is to download thousands of product images from my client site and make them transparent.
    They have provided me product codes and I have found out that they are using the same code in the link for that particular product.
    Is there any easy way to create increment links like
    myclientswebsite[dot]com/products/tv/5478-tv
    myclientswebsite[dot]com/products/tv/5479-tv
    myclientswebsite[dot]com/products/tv/5480-tv

    I'm dying doing this since i have another set to do which has thousands of images.
    A million thanks in advance.
    Last edited by jash; 08-06-2012 at 09:31 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,100

    Re: How to create auto increment hyperlinks in excel?

    Maybe a small macro.

    Select an empty sheet, Press Alt-F11 to open the VBE. From the Menu/Ribbon, Insert a new module. Copy and paste the code below.

    Change the value of the MaxRows to whatever you need, currently 1000.
    Change the value of the HLStart to whatever you need, currently 5477.

    Click anywhere between the Sub and End Sub and press F5 to run the code.

    It creates the hyperlinks but I can't test it because I don't have the real links, etc. Anyway, give it a go, see how far you get.


    Option Explicit
    
    Sub CreateHyperlinks()
    
    Dim i As Long
    Dim MaxRows As Long: MaxRows = 1000
    Dim HLStart As Long: HLStart = 5477
    
    Range("A1").Select
    For i = 1 To MaxRows
        With Range("A" & i)
            .FormulaR1C1 = _
                "=""myclientswebsite[dot]com/products/tv/""&ROW(RC)+" & HLStart & "& ""-tv"""
            ActiveSheet.Hyperlinks.Add _
                Anchor:=Range(.Address), _
                Address:= _
                    .Text
        End With
    Next 'i
    End Sub
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Chennai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to create auto increment hyperlinks in excel?

    Thank you very much for your reply TMShucks. I did as you said but i'm getting an error. Kindly take a look at the attached screenshot for more details screenshot.jpg

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,100

    Re: How to create auto increment hyperlinks in excel?

    Interesting though the picture is, the redacting is self defeating. I am left to guess what is in there and what might be causing the problem.

    I suspect that you may have spaces in there, where you didn't in the sample you quoted above. In that case, you'll probably need to put single quotes in there somewhere "to hold it together". But that's just a guess. Or maybe change spaces to %20. How secret is a web address?

    Regards, TMS

  5. #5
    Registered User
    Join Date
    08-06-2012
    Location
    Chennai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to create auto increment hyperlinks in excel?

    I'm sorry TMS it's completely my mistake. Your code is right, Its working fine for me now.
    Thank you very much and sorry again for causing such confusion.

    I'm advised by the client not to reveal their name since they are under major revamp
    their site is down for public but their products directory is open for my access.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,100

    Re: How to create auto increment hyperlinks in excel?

    You're welcome. What did you have to do to fix it?


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Registered User
    Join Date
    08-06-2012
    Location
    Chennai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: How to create auto increment hyperlinks in excel?

    I have no clue... I just copied your code again and pasted it over existing code... Tadaaan it worked fine... will mark this thread as solved.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,100

    Re: How to create auto increment hyperlinks in excel?

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1