+ Reply to Thread
Results 1 to 5 of 5

VBA Code Autofilter criteria and row deletion not giving result

  1. #1
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    VBA Code Autofilter criteria and row deletion not giving result

    I'm not sure, if i am starting this thread in under right sub-categories of General question, when it relates to specific VBA related issue.

    I have many macros running across 1000 plus lines, (So, not putting the entire code) but common line code are auto filtering rows based on certain condition and deletion thereof.

    Of late, I'm facing an issue where, if the code in its originality is run, i get the result - Auto filter row, based on some condition but later it does not delete the visible filtered rows, though there is no change in code, but am just copying pasting same criteria. Code is

    I want to retain the first row in sheet, which acts as header

    Please Login or Register  to view this content.
    Original code in another macro which does the job is -

    Please Login or Register  to view this content.
    Can someone tell me what logical error is preventing this? I'm using Excel version 97-2003, and currently have Installed Office 2013.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA Code Autofilter criteria and row deletion not giving result

    not the way i would do it

    i rejigged a version i had previously into this test data
    two sheets before and after

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by humdingaling; 02-08-2016 at 10:32 PM. Reason: special cells is delete not copy
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: VBA Code Autofilter criteria and row deletion not giving result

    @humdingaling, thanks for your response.

    Only suggestion I seek from you, and other valued members, is that you are using -

    With
    End With statement for Looping, together with ACTIVESHEET

    but I have similar criteria in different (say 8-10) columns, and there are multiple sheets and such critieria. Any alternative to speedup

    and I am specifying sheet name like

    Please Login or Register  to view this content.
    So, is there any way to shortern your suggestion? You are also creating variable on Column Q

    Further, I dont want any message / alert to appear, but simply macro do its job, as there could be many such instances of deleting rows

    Thanks for your time, and hope, i made my point clear.
    Last edited by analystbank; 02-09-2016 at 12:50 AM.

  4. #4
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    271

    Re: VBA Code Autofilter criteria and row deletion not giving result

    @humdingaling

    I modified your code, as under, to suit my purpose, and it does the job. Thanks Brother/Sir.

    Please Login or Register  to view this content.
    One more suggestion that i seek from you, now, is that, currently we are specifying Column A:Q, so, instead of restricting data filter upto column Q, how do we let excel auto decide filled column on Right side, say sometime A:Z, A:Q, or A:AB and so on, depending on data content in each sheet?
    Last edited by analystbank; 02-09-2016 at 01:54 AM.

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA Code Autofilter criteria and row deletion not giving result

    i used A:Q as an example, you can use A:AB for your filter range
    ie make it as large as you possible can make it
    it will still refer to field 17 (as long as A is your first column)

    or you can use a method to find the last column to define your specific range (see below URL on how this can be done)

    the lROW was used in this example as i knew that field 17 ie "Q"
    it doesnt have to be Q if your data is setup different
    you can use other ways to identify your last row
    its just without actual data i had to make an assumption


    http://www.rondebruin.nl/win/s9/win005.htm
    you can go go here to find out various method of last column/Row and see which one works for you
    Last edited by humdingaling; 02-09-2016 at 02:31 AM. Reason: additional info

+ 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. Adding date criteria from text box to autofilter code
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2014, 04:26 PM
  2. Help with autofilter code with 2 criteria
    By lylegross in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-23-2014, 08:13 PM
  3. [SOLVED] Simple =Sum(B2:L2) result is not giving accurate result and =IMSUM(M2,O2) also.
    By SimonsGE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-29-2013, 01:56 AM
  4. [SOLVED] Loop through Autofilter criteria and copy result
    By Elmholt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2013, 04:55 AM
  5. autofilter giving me jip??!
    By cashflowpro in forum Excel General
    Replies: 1
    Last Post: 04-17-2008, 11:48 AM
  6. Autofilter giving unexpected results!
    By Colin Vicary in forum Excel General
    Replies: 3
    Last Post: 09-28-2006, 07:20 AM
  7. [SOLVED] Formula not giving me the right result
    By Steved in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-09-2006, 10:25 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