+ Reply to Thread
Results 1 to 10 of 10

Filter Code is really slow, please Help...

  1. #1
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Talking Filter Code is really slow, please Help...

    Hello,

    And thank you in advance...

    I have a small issue with my Filter vba code. What I am trying to do is compare one worksheet column with another worksheet column and if any of the 1st worksheet column values are not found in the 2nd worksheet column those rows in the 1st worksheet will be hidden.

    Now I believe the coding works, but it is just to darn slow, and the screen flickers (Im using screenupdating.false as well) and it even goes black, not sure why? Any help would be appreciated.

    ***Correction: This code does not infact work, when it is ran it just hides all rows with values in them. So I am going to need some help here if anyone could spare some of their knowledge.

    Thank You

    My code:

    <code>

    Sub FilterSheet()
    Dim x As Integer
    x = 2
    Application.ScreenUpdating = False
    Do While Cells(x, 9) <> ""
    If Worksheets("Sheet1").Cells(x, 9).Value = Worksheets("Sheet2").Cells(x, 6).Value Then
    Else
    Worksheets("Sheet1").Rows(x).Hidden = True
    End If
    x = x + 1
    Loop
    Application.ScreenUpdating = True
    End Sub

    <code>
    Last edited by lanziniad; 12-14-2011 at 05:35 PM. Reason: Code doesn't work

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Filter Code is really slow, please Help...

    Hi lanziniad,

    Changing below code may help:-

    Please Login or Register  to view this content.
    Removed Else condition from above, also would appreciate if you post the sample file having this code to test further.

    Regards,
    DILIPandey

    <click on below 'star' if this helps >
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Re: Filter Code is really slow, please Help...

    Thanks for your reply.

    I will upload a copy in just a few minutes..

  4. #4
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Re: Filter Code is really slow, please Help...

    Here is the sample workbook
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Re: Filter Code is really slow, please Help...

    If I remove the else statement it will hide all the rows still, I need it to only hide the rows that contain values that are not in sheet 2

  6. #6
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Re: Filter Code is really slow, please Help...

    Hello forum,
    Just wondering if anyone had any thoughts or suggestions on this problem.
    Thank you.

  7. #7
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    Re: Filter Code is really slow, please Help...

    Hello Forum,

    Not sure why that last attachment was so big, I remade the workbook and it is quite a bit smaller, sorry....
    Attached Files Attached Files

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Filter Code is really slow, please Help...

    Hi lanziniad,

    Attached the file back with a query plus resolution, kindly look into the same.

    In the Hide (y/n) column you should get your desired results, else will be happy to explain. Thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps >
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-05-2011
    Location
    Missouri
    MS-Off Ver
    Office 2010, VBA 7.0
    Posts
    75

    [SOLVED] Re: Filter Code is really slow, please Help...

    Thank you for your help.....

  10. #10
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Filter Code is really slow, please Help...

    you are welcome lanziniad.

    cheers

    Regards,
    DILIPandey

    < click on below 'star' if this helps >

+ 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