+ Reply to Thread
Results 1 to 13 of 13

Quite a tricky SUM question

  1. #1
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Quite a tricky SUM question

    How to.png

    So I have a long list of numbers and letters that sometimes account for a different amount of values i.e. ?h?h could have a value of 1 or 6. So i would like to find a way that will allow me to assign different values to the data i have and then add them all together. I am not sure how to do this. So i could have an extra column that perhaps has an If ?h?h = a certain cell or IF ?s?s = certain cell. But i was wondering if there was an easier way to do this as that would be a lot of IFs. The pic probably explains better. Hope you can help.

    Thanks,

    Excel noob

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quite a tricky SUM question

    I am unable to understand your requirement from the picture you uploaded


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Quite a tricky SUM question

    Quote Originally Posted by :) Sixthsense :) View Post
    I am unable to understand your requirement from the picture you uploaded
    +1 to this.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Quite a tricky SUM question

    Sorry guys,

    Imagine the cells were names and i wanted to make every cell containing the name "Dave" = to 1 and every cell containing "Peter" = to 2 so that i could create a sum that would add them all up e.g.
    Dave
    Dave
    Dave
    Peter
    Dave would = 6

    But i have data like 2s2c and 4s3s. I want to assign the number to the letter part of the cell data which is why at the top of the pic i put a row with ?s?s as it doesn't matter about the number.

    So there is a long list of data that looks like this
    2s2h
    2c2s
    3s2s
    4s2s
    5s2s
    6s2s

    So, this data equates to a number e.g.
    3s2s = 1 and
    2s2h = 2
    or
    ?s?s = 1 and
    ?s?h = 2

    The problem i have is that what number they are, changes between spread sheets. The numbers in the cells don't mean much, it's the letters that change what number they equate to. So i wanted to have an input row at the top which that means
    Any cell containing
    two h's = 1 (?h?h)
    Any cell containing
    two s's = 1 (?s?s)
    Any cell containing
    A s and a h = 2 (?s?c)

    Sorry if i am being really confusing. I used ? as i know when you search a spread sheet and put ?s?s it will come back with all the cell that have those terms with the ? being anything.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quite a tricky SUM question

    Thanks for the brief and you will get the answer in seconds if you attach a sample workbook with expected output. Because your attached image doesn't cover the row/column references.

  6. #6
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Quite a tricky SUM question

    Helppp.xlsxThank you. I have attached a work book that i hope shows the situation a little clearer. I know i am probably not doing a great job explaining myself.

    EDIT: Please click the link in text for sheet
    Attached Files Attached Files

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Quite a tricky SUM question

    If your real data are as your sample data, then an option is this in my sample sheet..
    Attached Files Attached Files

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

    Re: Quite a tricky SUM question

    In C5 copied down;
    =INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0))
    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

  9. #9
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Quite a tricky SUM question

    Quote Originally Posted by ChemistB View Post
    In C5 copied down;
    =INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0))
    Does that work for you?
    that's perfect thanks very much Chemist

  10. #10
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Quite a tricky SUM question

    Quote Originally Posted by ChemistB View Post
    In C5 copied down;
    =INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0))
    Does that work for you?
    One final question. So at the moment it is looking at the letters i.e. ?s?s but is there a way to add a further condition based on the numbers so that if the numbers are the same (regardless of the letters) then it will always be 1.
    So
    2h2h =1
    3h3s =1
    Something like

    =IF(Range is X?X?,1,INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0))

    Thanks guys, been so much help

    lewgill

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

    Re: Quite a tricky SUM question

    =IF(MID(B4,1,1)=MID(B4,3,1), 1,INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0))
    How's that work?

  12. #12
    Registered User
    Join Date
    05-02-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Quite a tricky SUM question

    We are almost there! That seems to work but when copied down in to a blank cell it counts it as one instead of just N/A or 0 any ideas on how to stop this?

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

    Re: Quite a tricky SUM question

    Adding another if

    =IF(LEN(B4)>0,IF(MID(B4,1,1)=MID(B4,3,1), 1,INDEX($D$2:$H$2, MATCH("?"&MID(B4,2,1)&"?"&MID(B4,4,1),$D$1:$H$1,0)),"")

+ 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