+ Reply to Thread
Results 1 to 9 of 9

correct syntax for countif conditional delete in range...

  1. #1
    Registered User
    Join Date
    12-31-2015
    Location
    in the USA
    MS-Off Ver
    2007
    Posts
    19

    correct syntax for countif conditional delete in range...

    I am searching for the shortest syntax to modify this bit of code as follows;

    "for any rows in the range between col e and 0, delete the entire row, EXCEPT col A, only if the the cells in that range are either 1 or zero...for any values graeter than 1, dont delet etc..

    all input is most sincerely appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: correct syntax for countif conditional delete in range...

    Quote Originally Posted by morbenforsen View Post
    "for any rows in the range between col e and 0, delete the entire row, EXCEPT col A, only if the the cells in that range are either 1 or zero...for any values graeter than 1, dont delet etc..
    Not sure I follow your criteria.

    Delete row if E:O has at one cell with 0 or 1, or all cells are 0 or 1 ?

    Delete row except A? So delete B2:O2 if row 2 was to be deleted?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-31-2015
    Location
    in the USA
    MS-Off Ver
    2007
    Posts
    19

    Re: correct syntax for countif conditional delete in range...

    sorry let me try to clarify;

    in cols E:O if the values in that range are greater than 1, I want to keep the row intact. If the values are 1 or 0 I want to delete all of that row..EXCEPT column A.

    does that make more sense? thank you for your response!

  4. #4
    Registered User
    Join Date
    12-31-2015
    Location
    in the USA
    MS-Off Ver
    2007
    Posts
    19

    Re: correct syntax for countif conditional delete in range...

    more clarification: <<So delete B2:O2 if row 2 was to be deleted?>>

    would prefer the whole row except col a.

    edit; yes B2:02 would work for me in this case.
    Last edited by morbenforsen; 01-06-2016 at 06:28 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: correct syntax for countif conditional delete in range...

    Quote Originally Posted by morbenforsen View Post
    in cols E:O if the values in that range are greater than 1, I want to keep the row intact.
    Let me try again: Is the criteria for All 11 Cells in a row or Any One Cell in a row.
    Keep the row if all 11 cells are greater than one, or keep row if just one cell of the 11 is greater than one?
    Last edited by AlphaFrog; 01-06-2016 at 06:32 PM.

  6. #6
    Registered User
    Join Date
    12-31-2015
    Location
    in the USA
    MS-Off Ver
    2007
    Posts
    19

    Re: correct syntax for countif conditional delete in range...

    My apologies. ALL Cells in range. "If any value other than 1 or 0 appears anywhere in that row, then don't delete..otherwise delete."

    in B2:BO, DELETE IF:
    there are ONLY 1's and 0's
    OR if there are only 1's
    OR if there are only 0's.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: correct syntax for countif conditional delete in range...

    Here's one way...

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-31-2015
    Location
    in the USA
    MS-Off Ver
    2007
    Posts
    19

    Re: correct syntax for countif conditional delete in range...

    this seems to work...but Id' like to better understand what the Max function does in this case.

    why does this not fail if you have a row that contains all zeroes except 2 cells which contain "1" in each cell...

    help me understand this line exactly please?

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: correct syntax for countif conditional delete in range...

    The Max function returns the maximum (largest) value of the cells. If the maximum value is less than two, then no cells are greater than one.

+ 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. Syntax for number range in conditional formatting
    By Suzanne Irene in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 06-09-2015, 06:10 PM
  2. [SOLVED] What is wrong with my syntax? Trying to delete variable range of cells and shift up....
    By bg18461 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-04-2015, 12:03 PM
  3. [SOLVED] Correct syntax for function to find average based on background color of cells in range
    By moosetales in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-21-2014, 12:24 AM
  4. [SOLVED] Correct Syntax for Countif between values.
    By JO505 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-09-2013, 03:37 PM
  5. Correct syntax for using variable in range selection
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2012, 11:52 AM
  6. Getting the correct Syntax for Range in Sorting
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2011, 04:50 PM
  7. Replies: 1
    Last Post: 08-30-2005, 04: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