+ Reply to Thread
Results 1 to 8 of 8

"Not Responding" while code is running... need help with optimizing my code please!

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question "Not Responding" while code is running... need help with optimizing my code please!

    Hi VBA gurus,

    When i run my code, the application status shows the count but stops after a short while and it just turns to "Not Responding". Could it be that my code is inefficient? I'm not an expert at vba as its all mostly self-taught. please someone help!!!

    Alittle background:
    1. the code is found on a master workbook (which i leave open in the background), I then open a separate workbook each time to run the macro.
    2. the data starts from row 4 in each separate workbook.
    3. for each row of data found in a separate workbook- 2 points are used to trigger a match in the "ref" sheet of the master workbook. Namely: the active workbook's name and one other data points (sort of like a sumproduct/ 2 intersection)
    4. once the match is found, other data from the "ref" sheet is then copied over to the active workbook. and a string is introduced to another cell in the row as well

    Is there a more efficient way to do this??

    btw, i am running close to 25000 rows of data in one instance. and i have to do this for 15~20 separate workbooks

    Please Login or Register  to view this content.
    Last edited by dexcee; 08-27-2013 at 02:42 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    attach please a sample file for testing
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Hi, dexcee,

    if we knew what you are comparing we could give a better input on how to speed it up. I took the statusbar out. The roaming through the cells could be shortened by a Find-command so that one of the loops should become faster (or use a worksheetfunction.-Countif to find out if and how much hits will be there and exit the for after the according number fo hits).

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    05-28-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Thanks the replies HahoBe and Patel45,

    Unfortunately, i am unable to share the actual file, but i have placed random numbers in their place file...(as attached). I have also tried using IF-IF instead of the IF-And here. Appreciate the help guys!! Thanks!!!


    Area 1.xlsxMaster file.xlsm

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Hi, dexcee,

    you could use the Autofilter to narrow down the range in which to work in the ActiveWorkbook on Column E, check if there are any data sets being available by checking the last visible row (lngLast) to be equal to or greater than 4 and then run a For Each rngCell in wsAct.Range("E4:E" & lngLast).SpecialCells(xlCellTypeVisible) and compare that row to the other requirements instead of looping through the entire range for each item.

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    05-28-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Hi Holger,

    Thanks for the advice, but I am not too sure how to do that... do i have to manually filter before running the code? Thanks.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Hi, dexcee,

    filktering prior to running your code? That would narrow the visible number of rows down but not be any helpful.

    The loops should be restructured and the filter set on the value of wsRef.Cells(y, 16). If possible you could sort the reference sheet as well and only change the Autofilter in the ActiveSheet if a new value is found. This will cut down the number of actions to take dramatically.

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    05-28-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: "Not Responding" while code is running... need help with optimizing my code please!

    Hi Holger,


    Okay... I'll try to work something out along those lines. Thanks for the help!

+ 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. Running Code After "Opening File" Event Has Triggered Data Connection Refresh
    By david.nicholls in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2013, 07:22 AM
  2. [SOLVED] Code behaves differently between "step into" and running outright
    By theletterh in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 04-13-2012, 09:52 AM
  3. Excel and Outlook become "NOT RESPONDING" when running Macro
    By g1987 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2012, 03:28 PM
  4. Optimizing code time running
    By Pichingualas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2012, 12:13 PM
  5. Stop code from running when I click "Cancel"
    By Dean in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2006, 08:40 PM

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