+ Reply to Thread
Results 1 to 13 of 13

excel is slow when running macro on filtered cells

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    excel is slow when running macro on filtered cells

    hello


    i have this code which copies some columns from "temp file" to "target file".

    macro is working ok when there are no filtered cells in the "source file" but when i filtered 1 column in the "source file" and run the macro... my excel runs slowly. it still copies only the visible cells into the target file, but my problem is it is running very slow.

    i hope somebody can take a look at my code below and advise what is wrong. i wish it would run as fast as when there are no filtered cells in my temp file. note i know my code has a lot of errors, i am a newbie in macro so i only recorded it... :P if somebody can give me a better macro, i appreciate it...

    -----

    Please Login or Register  to view this content.
    Last edited by melody10; 09-21-2013 at 04:40 AM.

  2. #2
    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: excel is slow when running macro on filtered cells

    Hi, melody10,

    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)

    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

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    Edited... sorry...

    Hope somebody can help me now.

  4. #4
    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: excel is slow when running macro on filtered cells

    Hi, Melody,

    there is no indication about any filter in the code. I assume you might use
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    Maybe even add Application.ScreenUpdating ?= False at the start of the procedure and ~ = True at the end.

    Untested as CloseWorkbook isnīt available:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    hello holger

    i tried to edit my code with the one you gave me. but still no luck. macro still runs slow when i filter some columns.

    i have attached the sample file..

    when i filter column W and click on cargo readiness, some data should be transferred to the cargo readiness file...

    can you advise?
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    any advise from anybody?

  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: excel is slow when running macro on filtered cells

    Hi, Melody,

    you should work on a couple of the commands as it it a bit different to copy whole columns as opposed to just the filtered areas. I assumed that the data should be inserted after the formulas (so the range to copy to starts in Row 2001):

    Please Login or Register  to view this content.
    It took you more than four hours to answer but you want us to answer within less than half an hour? Maybe consider that itīs Saturday afternoon local time for me and somebody may have other/more important things to do than answer in an ExcelForum and that everybody here is in it for free. And I personally dislike posting code which is untested or may cause problems so Iīm trying to check the code thoroughly before posting (Iīm not failsafe to errors as you may have noticed with my first code and the testing takes itīs time). Maybe the code I posted here will raise errors when you run it on your machine - it didnīt do so on my side.

    Ciao,
    Holger
    Last edited by HaHoBe; 09-21-2013 at 10:08 AM.

  8. #8
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    I didn't mean to rush your answer. My apologies if you took it that way.

    and i appreciate you taking your time to look into my thread. I really do.

    thanks again. Ill try out your code and hopefully it works.

  9. #9
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    i did not understand the code you gave me, im sorry as i am a newbie.. when i replaced my code with your code, data are being copied to the same file name. it is supposed to be copied to the 2nd excel file (cargo readiness).

    the function of my original macro is working as i intend it to be.. my only problem is it is running very slow when i apply some filters. i am hoping anybody can point me at the right direction.

    thanks in advance.

  10. #10
    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: excel is slow when running macro on filtered cells

    Hi, melody10,

    from what you say I understand that oyu placed the code in Temp... while I would have expected it to be in Cargo... - my fault due to misunderstanding.

    Please alter
    Please Login or Register  to view this content.
    to read
    Please Login or Register  to view this content.
    The difference in the process is that you copy more than a million rows which are visible by selecting whole columns while I try to cut the amount down to just 2 rows as are visible in your sample. Next difference may be the next misunderstanding - you replace everything when pasting into the target workbook while I try to amend the data under what is present in the workbook.

    Ciao,
    Holger

  11. #11
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    hello holger

    thank you for your time...

    just last 1.... macro is already running fast as per your code...

    one problem... data should be pasted starting in row 8 of cargo readiness file... not in row 2001...

    please be patient with me...

  12. #12
    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: excel is slow when running macro on filtered cells

    Hi, melody10,

    one problem... data should be pasted starting in row 8 of cargo readiness file... not in row 2001...
    Not really a problem.

    My code was
    Please Login or Register  to view this content.
    which looks for the first available cell in Column E. You can use
    Please Login or Register  to view this content.
    instead but you might consider to delete any contents in the target sheet prior to copying because if you had copied three lines last time and there will be only two rows in the present process the third line would remain and might lead to unwanted action or confusion.

    please be patient with me...
    Iīm sorry if anything I wrote has sounded like being impatient - I can assure you I didnīt mean it that way.

    HTH,
    Holger

  13. #13
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: excel is slow when running macro on filtered cells

    thank you very much... my project is done....

    thanks soo much...

+ 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. Macro to hide/unhide cells not running or running slow
    By mbp727 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 04:22 PM
  2. Slow running macro when cells are hidden
    By bhsoundman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-18-2012, 02:33 PM
  3. Macro running slow
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-14-2012, 04:42 PM
  4. Excel 2007 : Macro running very slow
    By sidsinha in forum Excel General
    Replies: 1
    Last Post: 03-27-2012, 02:06 PM
  5. Macro running very slow
    By oo0tommyk0oo in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-22-2011, 03:14 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