+ Reply to Thread
Results 1 to 6 of 6

count alphanumeric codes only counting odd numbers not even numbers?

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    arizona
    MS-Off Ver
    Excel 2003
    Posts
    16

    count alphanumeric codes only counting odd numbers not even numbers?

    ok so I am trying to count a column of alphanumeric characters and I only need to know the odd numbered ones.

    example of the strings: YP213
    YP212
    YP213B
    YP212B
    YP202
    YP203
    YP203B
    ETC.....

    so any ideas on how to count these even though some of them end in letters? all I need is to be able to tell if the number is odd and how many of them are there? I need to add this into a countifs function :
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    in case that makes a difference? the countifs works fine already but I cannot get it to incorporate the odd number count. please help!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: count alphanumeric codes only counting odd numbers not even numbers?

    Do the strings ALWAYS start with 2 letters followed by a 3 digit number?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    02-22-2013
    Location
    arizona
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: count alphanumeric codes only counting odd numbers not even numbers?

    there is always a 3 digit number but sometimes there are 2 letters in front and sometimes there are 3 letters. there will only be one letter at the end.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: count alphanumeric codes only counting odd numbers not even numbers?

    You won't be able to include this in your COUNTIFS formula.

    You might be better off extracting the number first and then testing for MOD(number,2)=0.

    If this is your data in the range A1:A7...

    YP213
    YP212
    YP213B
    YP212B
    YP202
    YP203
    YP203B

    Enter this formula in B1 and copy down:

    =IF(COUNT(1*RIGHT(A1)),--RIGHT(A1,3),--LEFT(RIGHT(A1,4),3))

    Then you can use the range B1:B7 to test for even numbers.

    MOD(A1:A7,2)=0

    You'll have to use something like this:

    =SUMPRODUCT(--(MOD(A1:A1968,2)=0),--(F1:F1968="GLOCK"),--(G1:G1968="SW"))

    If you just want the count of even numbers then try this array formula**:

    =SUM(IF(MOD(IF(ISNUMBER(1*RIGHT(A1:A7)),--RIGHT(A1:A7,3),--LEFT(RIGHT(A1:A7,4),3)),2)=0,1))

    This one will only work in Excel 2007 and later:

    Array entered**:

    =SUM(--ISEVEN(IF(ISNUMBER(1*RIGHT(A1:A7)),--RIGHT(A1:A7,3),--LEFT(RIGHT(A1:A7,4),3))+0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: count alphanumeric codes only counting odd numbers not even numbers?

    Argh!

    I only need to know the odd numbered ones.
    I guess I wasn't paying attention. The formulas I posted are based on counting the EVEN numbers, not the odd numbers.

    However, the fix is fairly easy.

    =SUMPRODUCT(--(MOD(A1:A1968,2)>0),--(F1:F1968="GLOCK"),--(G1:G1968="SW"))

    Array formulas**:

    =SUM(IF(MOD(IF(ISNUMBER(1*RIGHT(A1:A7)),--RIGHT(A1:A7,3),--LEFT(RIGHT(A1:A7,4),3)),2)>0,1))

    =SUM(--ISODD(IF(ISNUMBER(1*RIGHT(A1:A7)),--RIGHT(A1:A7,3),--LEFT(RIGHT(A1:A7,4),3))+0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  6. #6
    Registered User
    Join Date
    02-22-2013
    Location
    arizona
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: count alphanumeric codes only counting odd numbers not even numbers?

    the sum product isn't working it keeps giving me a value# error? and the 2 array formulas wont work if I change the cells from A to B columns or change the rows from 7 to 1968?

+ 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. Replies: 6
    Last Post: 12-22-2012, 05:04 PM
  2. [SOLVED] Count numbers between two values in a coma delimited string of numbers
    By van23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2012, 11:42 PM
  3. [SOLVED] Take out a set of numbers from alphanumeric cells
    By Adys747 in forum Excel General
    Replies: 6
    Last Post: 11-20-2012, 06:56 PM
  4. Replies: 8
    Last Post: 09-30-2009, 11:10 AM
  5. [SOLVED] Count comma separated numbers, numbers in a range with dash, not t
    By Mahendra in forum Excel General
    Replies: 0
    Last Post: 08-08-2005, 01: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