+ Reply to Thread
Results 1 to 9 of 9

Column disappear when using advanced Filtering through VBA

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Column disappear when using advanced Filtering through VBA

    Hi, I'm struggling to understand why after the first loop (Z=2) all of a sudden column A in WS ATT disappears. Worth adding that column M in WS L is a "dynamic" range (at first it contains 7 cells) in the sense that it shrinks with each loop (M2:M8, second loop: M2:M7 etc.). I can produce a sample, but maybe somebody see why my prob. is happening through this code?

    Please Login or Register  to view this content.
    Last edited by GIS2013; 07-09-2014 at 05:22 PM.
    Please * if you like the answer

  2. #2
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Column disappear when using advanced Filtering through VBA

    It gets even more weird. The porblem is "solved" only if I select the second worksheet (one of the two that exists before running the loop above). I cannot see the logic here..

    If it may help here is the full code
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Column disappear when using advanced Filtering through VBA

    Have you checked what's actually selected before you delete the Selection?

    PS Bad idea calling a sub Delete.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Column disappear when using advanced Filtering through VBA

    Hi Norie,
    Yeah I'll change the name.
    As to the selection: it's a loop, for example Z=2 TO 5, so in each loop the M column is shrinking.
    This was my solution (I guess that are better) to the fact that in advanced filtering you must provide contagious range..

    Clarification: in the criteria range "A1:N2" I always filter by a specific field ("M1") and each time M2 is changing. And each soltion is copied into a new sheet which is added and named after the M2.value
    Last edited by GIS2013; 07-09-2014 at 05:29 PM.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Column disappear when using advanced Filtering through VBA

    But have you checked what's actually selected before you delete it?

    One of the pitfalls of using Select/Selection is that you can never actually be sure what's selected.

    The right sheet might not even be selected.

    If you use explicit workbook/worksheet/range references you shouldn't have that problem.

  6. #6
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Column disappear when using advanced Filtering through VBA

    Thanks Norie . Let me revise my whole code and meanwhile mark this thread as solved.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Column disappear when using advanced Filtering through VBA

    Is it solved?

    Have you rectified the problem with the disappearing column?

  8. #8
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Column disappear when using advanced Filtering through VBA

    I'll check your direction tomorrow (and update). For now the "patch" is just to activate L (which is a worksheet) just before running the loop. Some how it works this way without "deleting" the first column.

  9. #9
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Column disappear when using advanced Filtering through VBA

    Norie, you were right, explicit reference has made the difference. I've changed:
    this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    And now no column is got lost..

+ 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] Easy filtering method via vba/formula/advanced filtering?
    By jedemeyer1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-10-2014, 12:35 AM
  2. More advanced advanced filtering
    By Acceleracer in forum Excel General
    Replies: 2
    Last Post: 02-06-2014, 09:02 PM
  3. Advanced Filtering
    By jn_mohit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 02:06 AM
  4. [SOLVED] advanced filtering in XLS
    By Debra Dalgleish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 05:05 PM
  5. Advanced Filtering
    By CFL in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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