+ Reply to Thread
Results 1 to 12 of 12

Memory problem/slow macro

  1. #1
    Forum Contributor
    Join Date
    04-19-2009
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2010
    Posts
    130

    Memory problem/slow macro

    Hello all. The following code performs the desired task though not until completion. There are roughly 200 hyperlinks with 6 elements taken from each link. Is there any way that I can speed this up/free up memory? It is incredibly slow and then blocks at 200 odd elements. Any help greatly appreciated.

    Cheers
    Dan

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Memory problem/slow macro

    Hi, my first question.
    Does it really stop or does it just say Excel is not responding (in French if your interface is French)
    You must know, and I fell for it too, that Excel keeps working in the background. This started with Excel 2007 because of the way it is written.
    The entire concept of how it works has changed.
    The UI (User Interface) stops working but in the background the code is still busy even though you cannot press Ctrl + Break or interrupt.
    Patience is the only option.
    You can add a status bar update to see but this also stops.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Memory problem/slow macro

    I include this code before and after the main macros
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Memory problem/slow macro

    Dan,
    You are using not the most efficient scrapper. I do not know if you know HTTP object. It is unobtrusive and much robust than IE.

    I can't say more unitl I see and test the URLs.

  5. #5
    Forum Contributor
    Join Date
    04-19-2009
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2010
    Posts
    130

    Re: Memory problem/slow macro

    Thank you for the replies.

    Keebelah they do say patience is a virtue though I do not have it in droves. I will have a look at what you suggest and see if it improves things. Though it does seem incredibly slow for what really is a simple scrape. Hello again AB here is an example link
    HTML Code: 
    I am scraping the names and populating sheet 2. No I am not familiar with http object. Will check it out. Thanks again to both of you.

    Cheers
    Dan

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Memory problem/slow macro

    Here we go!

    I have tested it using the URL's you just posted. You need to make some changes for the code to work on your real data:

    searchUrl should be replaced by cel– the values in each row in sheet1
    You also need to tick HTML librarry in Tools- References- MSHTML OBJECT LIBRARY

    Please Login or Register  to view this content.
    Last edited by AB33; 10-26-2018 at 08:27 AM.

  7. #7
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Memory problem/slow macro

    Hi. You *can* avoid using IE but you may need to use early-binding. In VBA, go to Tools/References and check the boxes next to "Microsoft HTML Object Library" and "Microsoft XML, v6.0". Then you could try the following:

    Please Login or Register  to view this content.
    The DoEvents line hopefully keeps Excel from going to "Not Responding" and would allow you to break into your code.

    WBD
    Office 365 on Windows 11, looking for rep!

  8. #8
    Forum Contributor
    Join Date
    04-19-2009
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2010
    Posts
    130

    Re: Memory problem/slow macro

    Hello, Both codes worked very well. Need to learn about this. So fast. Thanks a heap AB and Wideboy. Much appreciated.

    Cheers
    Dan

  9. #9
    Forum Contributor
    Join Date
    04-19-2009
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2010
    Posts
    130

    Re: Memory problem/slow macro

    Hello would like to pick you brains again. The names come out in a continuos list which is ok but not ideal. I would like to keep each link grouped ie keep each links elements separated by an empty row. How would one go about doing this?

    Cheers
    Dan

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Memory problem/slow macro

    Do you mean you want to insert an empty row for each URL?
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    04-19-2009
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2010
    Posts
    130

    Re: Memory problem/slow macro

    Hello AB,

    Cheers mate. Exactly what I was after. I had entered the wrong variables and was getting an error. Stupid. Thanks for all your help.

    Dan

  12. #12
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Memory problem/slow macro

    Quote Originally Posted by Cicada View Post
    Hello would like to pick you brains again. The names come out in a continuos list which is ok but not ideal. I would like to keep each link grouped ie keep each links elements separated by an empty row. How would one go about doing this?

    Cheers
    Dan
    You would add an extra line here:

    Please Login or Register  to view this content.
    WBD

+ 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. [SOLVED] Thrashing VBA Memory Leaks. Memory Loop Problems. Uncleared Memory in .Match Range Object
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2017, 05:17 PM
  2. Memory too full - system too slow
    By mitrozo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2016, 04:23 PM
  3. [SOLVED] Solving a slow excel file which uses over 1GB of memory.
    By bennieboi20 in forum Excel General
    Replies: 18
    Last Post: 10-24-2016, 04:24 AM
  4. Memory resident macro with multiple web connection problem.
    By shailew in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2014, 02:23 AM
  5. Excel Slow down and Memory hog!!
    By mongoose36 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-11-2014, 09:49 AM
  6. Memory problem from macro creating and naming sheets from Array?
    By acj06 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2011, 02:23 PM
  7. [SOLVED] Routine running slow (memory leak?)
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2006, 07:25 AM

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