+ Reply to Thread
Results 1 to 13 of 13

Read only the number value of a cell

  1. #1
    Registered User
    Join Date
    06-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Read only the number value of a cell

    I am trying to get a SUM function to recognise values within a range of cells, that are immediately followed by a *. i.e. 34*

    For each range i need to count the total number of inputs, count the number of starred inputs & add up all the values entered.

    Currently COUNT doesn't recognise starred values, COUNTIF is set to count only starred values, and SUM wont recognise the value of the starred values.

    Is there a way to only read the number element of an input - there are only integer values & starred integer values. The starred inputs are also conditionally formatted. If there is a way would it then affect the COUNT/COUNTIF element?

    regards

    Pedro

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,083

    Re: Read only the number value of a cell

    Can you upload an example?
    Never use Merged Cells in Excel

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

    Re: Read only the number value of a cell

    Not THE Pedro Collins ? It sounds like a cricket related question too...

    You can count instances using COUNTA(A1:A100) which will count both numbers and text.

    To count * you can as you say use: COUNTIF(A1:A100,"*")

    To sum all values you could use for ex.

    =SUMPRODUCT(--(SUBSTITUTE("0"&A1:A100&"*","*","")))

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Read only the number value of a cell

    to count values with *
    Please Login or Register  to view this content.
    to count Unstarred values

    Please Login or Register  to view this content.
    to sum all values including *'d values

    Please Login or Register  to view this content.
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Read only the number value of a cell

    would have sugested countif but assumed * would be taken as a wildcard

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

    Re: Read only the number value of a cell

    Hi Squiggler, re: the summation... I agree with the SUBSTITUTE approach and you've shown I have a superfluous addition of * to the strings but so as to handle possibility of blanks it would be a good idea (I think) to append the string with "0" ... this way blanks become 0 and the coercion from string to number won't error.... so I would go with:

    =SUMPRODUCT(--("0"&SUBSTITUTE(A1:A100,"*","")))

    (all based on OP assumption that values are always either number or number * ... the 0 is to offer future capacity (ignoring DNR))

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

    Re: Read only the number value of a cell

    Quote Originally Posted by squiggler47 View Post
    would have sugested countif but assumed * would be taken as a wildcard
    It is really, but it's signifying text requirement so the numbers are ignored... if you added say "a" to the range of values

    =COUNTIF(A1:A100,"*")

    would count it, it's not in that form really counting instances of * ... to do that you would precede the * with ~ so as to have it treated literally

    =COUNTIF(A1:A100,"*~*")

    so something* .. this would ignore the "a"

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Read only the number value of a cell

    yes I would agree donkey, but the ambiguity of
    countif(a1:a100,"*")

    not being a wild card but

    countif(a1:a100,"3*")

    is is a little annoying!

    and I would probably have done 0& rather than "0"& (just from lazyness!)

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

    Re: Read only the number value of a cell

    I am assuming our last posts crossed...

    countif(a1:a100,"*")

    the above is a wildcard approach, and

    countif(a1:a100,"3*")

    would obviously only count text strings beginning with 3.

    To count strings containing an * in a literal sense you would use tilde

    countif(a1:a100,"*~*")

    thereby stating you're looking to count text strings that end with an asterisk.

  10. #10
    Registered User
    Join Date
    06-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Read only the number value of a cell

    attached is the example....

    Sadly for me i am a mere Peter Collins, but it is cricket related!

    the starred values are Not Outs.. and thus the value is used in the average but it is not "counted" when dividing through.

    cheers

    Pedro

    ps.. i am row 8..
    Attached Files Attached Files
    Last edited by PedroCollins; 06-12-2009 at 05:45 AM. Reason: grammatical

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

    Re: Read only the number value of a cell

    OK so adapting the examples provided thus far:

    U3: =SUMPRODUCT(--(0&SUBSTITUTE(A3:R3,"*","")))
    copy down

    V3: =MAX(--(0&SUBSTITUTE(A3:R3,"*","")))
    committed with CTRL + SHIFT + ENTER
    copy down... note this won't denote * if MAX was unbeaten as was the case with your 1/2 century!

    Y3: =IF(S3-T3,U3/(S3-T3),0)
    copy down

    You could also alter approach in S:

    S3: =COUNTA(A3:R3)
    copy down

    And to avoid confusion...

    T3: =COUNTIF(A3:R3,"*~*")
    copy down
    Last edited by DonkeyOte; 06-12-2009 at 06:32 AM.

  12. #12
    Registered User
    Join Date
    06-12-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Read only the number value of a cell

    many thanks for your help... it works like a charm. i will now be spending a bit of time reading up on WHY it works!!

    i may well be back on asking for a few other bits of advice as the sheet builds. i am an Excel Novice so the sheer volume of functions is often baffling... it's difficult to explain what i am looking for to the outdated excel manual i have here...

    Cheers

    Pete "Pedro" Collins.... Averaging 22...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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