+ Reply to Thread
Results 1 to 7 of 7

Eliminating even or odd numbers

  1. #1
    Forum Contributor
    Join Date
    11-13-2010
    Location
    Warren, Michigan
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    307

    Eliminating even or odd numbers

    In separate columns I am trying to eliminate either all "EVEN" or all "ODD" numbers.

    See sample –

    The coding I'm using is:

    ODD
    =IF($J$1="ODD",IF(A2="","",IF(MOD(A1,2)=0,A2,"")),A2)

    EVEN
    =IF($N$1="EVEN",IF(A2="","",IF(MOD(A1,2)=1,A2,"")),A2)

    When I first look the coding appeared to work, but on second glance it obviously wasn't.
    Attached Files Attached Files
    Last edited by NBVC; 03-24-2011 at 03:34 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Eliminating even or odd numbers

    For the first column
    =IF($C$1="ODD",IF(A2="","",IF(MOD(A2,2)=1,A2,"")),A2) although since you know C1 = ODD, you can shorten that to
    IF(A2="","",IF(MOD(A2,2)=1,A2,""))

    For the Even Column
    =IF($E$1="EVEN",IF(A2="","",IF(MOD(A2,2)=0,A2,"")),A2)
    or
    =IF(A2="","",IF(MOD(A2,2)=0,A2,""))
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Eliminating even or odd numbers

    Try:

    =IF($C$1="ODD",IF(A2="","",IF(SUMPRODUCT(--(LEN(A2)-LEN(SUBSTITUTE(A2,{1,3,5,7,9},""))))>=2,A2,"")),A2)

    and

    =IF($E$1="EVEN",IF(A2="","",IF(SUMPRODUCT(--(LEN(A2)-LEN(SUBSTITUTE(A2,{0,2,4,6,8},""))))>=2,A2,"")),A2)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Eliminating even or odd numbers

    try for odd =IF(--ISODD(LEFT(A2))+(--ISODD(MID(A2,2,1)))+(--ISODD(RIGHT(A2)))>1,A2,"")
    or =IF(SUM(--ISODD(LEFT(A2)),(--ISODD(MID(A2,2,1))),(--ISODD(RIGHT(A2))))>1,A2,"")

    for even
    =IF(--ISODD(LEFT(A2))+(--ISODD(MID(A2,2,1)))+(--ISODD(RIGHT(A2)))>1,"",a2)
    or
    =IF(SUM(--ISODD(LEFT(A2)),(--ISODD(MID(A2,2,1))),(--ISODD(RIGHT(A2))))>1,"",a2)
    Last edited by martindwilson; 03-24-2011 at 10:01 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    11-13-2010
    Location
    Warren, Michigan
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    307

    Re: Eliminating even or odd numbers

    Everyone thanks for your help.

    So many solutions.

    I've attached an updated sample.
    Attached Files Attached Files

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Eliminating even or odd numbers

    Yet another alternative:

    Please Login or Register  to view this content.
    the above could be applied to both columns simultaneously (no need for modification)

  7. #7
    Forum Contributor
    Join Date
    11-13-2010
    Location
    Warren, Michigan
    MS-Off Ver
    Excel 2008 for Mac
    Posts
    307

    Re: Eliminating even or odd numbers

    That also works. Thanks. Now I'm playing around with eliminating all repeat digit numbers from the ODD and EVEN columns - 551, 889, etc.

+ 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