+ Reply to Thread
Results 1 to 16 of 16

Run the same macro for 30 urls

  1. #1
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Run the same macro for 30 urls

    Hello!
    First of all please excuse me for my bad english and lack of vba language because I am new to the forum and just started learning VBA.
    So basically I have a working macro that downloads a table from a website, it's not the best way to do it but it does the job.
    The problem is that I want to make this code download tables from 30 urls in a single run so that I don't have to constantly change the url in the code.
    Here is the code.

    Please Login or Register  to view this content.
    My guess was that I must put this in a loop that will take the urls from another sheet.
    There is only one table on every webpage that it downloads from.
    Last edited by Hagea_Dan; 08-14-2014 at 04:46 PM. Reason: This post did not comply with Rule 3 of this Forum

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Run the same macro for 30 urls

    i would list the URL's somewhere on the sheet and for a for...next loop

    The syntax would be


    Please Login or Register  to view this content.
    Or something like that
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  4. #4
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    Quote Originally Posted by StephenR View Post
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Sorry about that. I hope this fixed the problem.

  5. #5
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    Please Login or Register  to view this content.
    I can't get pass the Connection:=MyURL.Offset( i -1 , 0).value line. Isn't this the correct syntax? I get error 1004.

  6. #6
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    I managed to make it work but it's rather primitive. It work only if I'm on the "links" sheet. How can I make this work regardless on what sheet I am?

    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    Just use
    Please Login or Register  to view this content.
    and it will reference the active sheet.
    Last edited by StephenR; 08-15-2014 at 08:28 AM.

  8. #8
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    The thing is I want to make a dashboard so I don't want it to reference the active sheet.

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    Either you add a specific sheet reference as you did before or none, which will refer the active sheet. Which sheet should be referenced?

  10. #10
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    The sheet name that I want to reference is "links". The code works but only on the "links" sheet.
    I want to run the code from another sheet but to take the websites adresses from the "links" sheet.

  11. #11
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    OK so use
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    Quote Originally Posted by StephenR View Post
    OK so use
    Please Login or Register  to view this content.
    I tried it already and it doesn't work. After Sheets("links")."must be a range" otherwise it gives an error.

    Please Login or Register  to view this content.
    It works fine like this but only on the links sheet. I don't understand why because is referenced.

  13. #13
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    No you haven't fully referenced your range. I'd be surprised if mine wouldn't work but I see I used a colon instead of a semi-colon.

  14. #14
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    How can I fully reference then?

  15. #15
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    Use my code, or use
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    08-14-2014
    Location
    London, England
    MS-Off Ver
    MS Office 2013
    Posts
    12

    Re: Run the same macro for 30 urls

    It works! Thank you so much!
    Sorry for bothering you with this thing but I just started to learn.
    Have a nice day!

  17. #17
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run the same macro for 30 urls

    Glad we got there.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help with macro to automate web queries (with URLs in cells)
    By BBallExcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 01:46 PM
  2. Macro to make URLs Live In Worksheets
    By tdm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2012, 03:19 AM
  3. Converting text URLs to hyperlinked URLs
    By ranchhand in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2011, 01:46 PM
  4. Macro to Auto generate URLs
    By grahammc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2010, 11:46 PM
  5. macro - creating URLs
    By morgonzola in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2007, 05:44 PM

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