+ Reply to Thread
Results 1 to 6 of 6

Second Advanced Filter does not work based on the data generated from the filter

  1. #1
    Registered User
    Join Date
    08-28-2011
    Location
    Vancouver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Second Advanced Filter does not work based on the data generated from the filter

    Hello everyone,

    I am relatively new to Macro, so rather from writing it, I use Macro recording.

    After pressing the hot key (Crtl + Shift + P), the first advanced filter works.

    It is based on A B C D columns and generates 4 new columns, F G H I, based on the criteria of E1 and E2.

    The second filter does not work.

    Second advanced filter is based on the unique of Column G and generate into Column K.

    However, this filter only generates the header (the column title) but no data. When I do it manually, there are header as well as filtered data.

    Does anyone catch any mistake in the code? I have researched online for a long time, but I still cannot figure out why it works manually but not in macro.

    Thank you for the kind considreation,

    Mucc



    [Sub NEWFILTER()]
    '
    ' NEWFILTER Macro
    ' Filter
    '
    ' Keyboard Shortcut: Ctrl+Shift+P
    '

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mucc1928; 08-29-2011 at 08:34 AM.

  2. #2
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Second Advanced Filter does not work based on the data generated from the filter

    Hi Mucc

    Please add code tags to your code

    See Rule #3 Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button).

    Having done so, I'll post a solution that seems to work.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    08-28-2011
    Location
    Vancouver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Second Advanced Filter does not work based on the data generated from the filter

    Hello I have edited the post and get a code tag. Thanks.

  4. #4
    Registered User
    Join Date
    08-28-2011
    Location
    Vancouver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Second Advanced Filter does not work based on the data generated from the filter

    Can someone please give me a hint on what should I edit?

    It works manually, just no in macro.....

    Thanks

  5. #5
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Second Advanced Filter does not work based on the data generated from the filter

    Hi Mucc

    This code is in the attached and appears to do as you describe
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-28-2011
    Location
    Vancouver
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Second Advanced Filter does not work based on the data generated from the filter

    Hello Jaslake,

    Thank you very much for your help.

    The code works as you said, which is perfect! I also want to understand the logic behind.

    What does " LR = .Range("B" & .Rows.Count).End(xlUp).Row" stand for here?

    I thought my criteria is E1 and E2, but how come it becomes G1:G? I just want to understand the logic behind.

    I tried to find more info about LR...but i don't have much luck online. Does it stand for Long Range?

    Thanks for all the help once again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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