+ Reply to Thread
Results 1 to 5 of 5

condition based deletion - using loop

  1. #1
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    condition based deletion - using loop

    This code take column index and condition for deleting the entire row.

    Due to my limited exposure to VBA I am unable to figure out why this is not working.

    Please suggest.

    Govind


    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: condition based deletion - using loop

    Forget the code for a moment, can you tell us:

    1) what your condition for deletion is?
    2) what column your checking?
    3) where in the column you are starting (looks like row 2)
    4) what determines when to stop (empty cell in that column?)
    5) is there additional data in that column further down or does the last cell with data in that column tend to represent the bottom of the data on that sheet?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: condition based deletion - using loop

    Or, just give this alternate version a try:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: condition based deletion - using loop

    hi,

    I have tried your code.. its seeems to be not working as well..
    Please see the attached file.. i am trying to remove second row with value 2

    Govind
    Attached Files Attached Files

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: condition based deletion - using loop

    See, it always pays to start with a worksheet. The question is: "Are you always filtering by a numeric string?"

    The culprit is this line of code:
    Please Login or Register  to view this content.
    ..which I used directly from your original formula. TYPE 2 is "string" or text. The number "2" as a filter criteria isn't accurate enough.

    Change that to TYPE:=1 for "numeric" and it works fine FOR NUMBERS only.

    If you want a permanent solution that works for anything (numerics or text strings as a filter), then use BOTH like so:
    Please Login or Register  to view this content.
    This will spot numbers as numbers and only match to numbers, spot text strings as text and treat them likewise.
    Last edited by JBeaucaire; 05-02-2009 at 07:41 PM.

+ 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