+ Reply to Thread
Results 1 to 19 of 19

How to loop through filtered advanced filter range ?

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    How to loop through filtered advanced filter range ?

    Hi

    i have code where i am using:

    Please Login or Register  to view this content.
    so xlCellTypeVisible is for loop in an range.

    My questions are :

    1. is there any faster way of looping through visible cells in advanced filter?
    2. How to loop only through specific columns (like with ColumnIndex = 4) in visible cells?


    I was thinking to make the array from visible cells but it is working on all data, not only visible ones.

    Please help,
    Jacek
    Last edited by jaryszek; 06-13-2023 at 05:31 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: How to loop through filtered advanced filter range ?

    You could simply filter the data to another range somewhere, then load that into an array.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    I was thinking to make the array from visible cells but it is working on all data, not only visible ones.
    Upload sample file and will show you...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    Thank you Rory,

    it seems easy solution but i am stubborn and want to get this in place and didn't find it on web.
    Plus i had to do some changes in created array and replace it with source range....(like removing rows)

    Sintek,
    i attached the workbook.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: How to loop through filtered advanced filter range ?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    So what is output...Just want to loop columns(4) if ABC = F2G2H2 OR UPDATE Col 4 values

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    Thanks jindon,

    Sintek --> yes just want to loop through column 4.

    Best,
    Jacek

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    Then why want to filter and then loop...
    Just loop each cell and see if Col A-C matches criteria and if so then do Whatever?
    Unless you are wanting something else which you have not specified...

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: How to loop through filtered advanced filter range ?

    2. How to loop only through specific columns (like with ColumnIndex = 4) in visible cells?
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    Thank you jindon,
    Sintek just output cellValue to the console

    Best,
    Jacek

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    I think there are 3 options:

    either creating array as jindon showed either loop through visible cells either copying into new worksheet.

    But copying into new worksheet and array will not work for my goal which is also removing rows.
    So i have to do this inside already existing range.

    Visible cells for now is staying.

    Once again, thank you very much Guys!!!

    Best Wishes!
    Jacek

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    But copying into new worksheet and array will not work for my goal which is also removing rows.
    So i have to do this inside already existing range.
    You have still not clearly explained what it is you are ultimately wanting to achieve as you have not provided an expected outcome...
    You just say loop through filtered cells...
    Sintek just output cellValue to the console
    What is this console?
    Now you say you want to remove rows...
    So what is it you actually want?
    Last edited by sintek; 06-14-2023 at 03:43 AM.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: How to loop through filtered advanced filter range ?

    jaryszek,

    I feel like you don't want me to reply to your thread, so don't worry no more reply from me.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    Thank you Guys.

    Sintek,

    let me show you expected output in workbook attached.

    jindon,

    i love your methods and already know it from our previous posts. thank you so much for that!

    But in this case maybe i was not clear.
    If i will filter and put rows in the array i will not able to remove rows/ change something there.

    Let me add workbook as attachment with expected output.
    Attached Files Attached Files
    Last edited by jaryszek; 06-14-2023 at 04:22 AM.

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    Seems jindon can read your mind so I'm very certain he will give you a solution...

  16. #16
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    Please check file sintek i showed expected output as you wanted.
    I hope it is clear now.

    Best,
    Jacek

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    yes most certainly, however, you do not explain the steps to get the result...
    What has that file and output got to do with your initial filter and then having rows removed...Where oh where is the code supposed to get the name change...
    DnsZoneId was changed to DnsZoneId2
    was delated because of "DnsZone" string inside AttributeName
    I mean what does above even mean...

    Like I say...Mind Reader I am not...jindon has already offered two solutions
    The second answers your initial
    How to loop through filtered advanced filter range
    Both still don't achieve what you are actually wanting...
    this is Table where i will change/remove rows
    This table is blank????

    You are either going to have to hard code all the required changes or store these changes in a sheet...
    So...Go back to drawing board and explain step by step what it is you are wanting this code to do...
    Last edited by sintek; 06-14-2023 at 04:54 AM.

  18. #18
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to loop through filtered advanced filter range ?

    I want to :

    1) filter SourceData table per "Table2" using advance filter or whatever but IN PLACE.
    2) loop through filtered rows and if AttributeName ="DnsZoneId" change it to "DnsZoneId2"
    3) Remove row in filtered range where AttributeName = "DnsZone"

    Thanks for helping,
    Jacek

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: How to loop through filtered advanced filter range ?

    So IF ABC = F2G2H2 then
    If D = DnsZone then delete row
    If D = DnsZoneId then change to DnsZoneId2

    Please Login or Register  to view this content.
    Last edited by sintek; 06-14-2023 at 05:31 AM.

+ 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] filter to array not advanced filtering for second loop
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2019, 08:27 AM
  2. Copy only filtered results of advanced filter
    By csh8428 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2013, 04:51 PM
  3. Advanced filter with some conditions & copy filtered value to next sheet
    By sudhirkumar3429 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-24-2012, 05:46 AM
  4. Advanced Filter VBA - Keeping the non filtered info
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2011, 09:06 PM
  5. Excel 2007 : Loop Through Advanced Filter Unique Records
    By Wrecking_Crew in forum Excel General
    Replies: 5
    Last Post: 03-21-2010, 01:20 PM
  6. [SOLVED] advanced filter a range:Advanced Filter function
    By Il Principe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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