+ Reply to Thread
Results 1 to 2 of 2

Conditional statements

  1. #1
    Registered User
    Join Date
    01-09-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    4

    Conditional statements

    Thank you very much for your help Paul. The solution, which I don't fully understand, works brilliantly!


    Hello,

    A little while ago a posted a question in this forum and I received a very helpful answer. Thank you for that; it was very much appreciated. I hope that one of you Excel geniuses out there can help me again.

    Attached you should find a simplified version of the problem I'm facing. I have a large number of product data that needs to be codified according to different categories. Specifically, there are various products in 3 different rooms (room 1, 2 and 3 see column A). Each product has a description (column B) which results in a manually assigned value that determines the code of the product (code 1, 2, 3 or 4 see Column C). The "results table" needs to count each product according to its code but by taking into account the room that the product is in. For example, in F9 the value 2 was derived by counting the occurrences of products in room 1 which were assigned code 1. Similarly H11 shows 0 products with code 3 in room 3. Please note that if necessary I could use absolute cell positions.

    Is there a formula that will enable me to do these ‘calculations’? Using pseudo code I'd write something like this:

    IF (code = 1 and room 1 = true) then add 1 to counter in F9 else
    IF (code = 1 and room 2 = true) then add 1 to counter F10 else
    etc.

    I really hope this makes sense to someone out there who's willing to spare a few minutes to work out a solution. It goes without saying that I haven't been able to come up with anything that works and doesn't involve 50 different temp values being used as 'flags' in different cells!

    Many thanks
    Attached Files Attached Files
    Last edited by gigaworks; 01-28-2010 at 07:47 AM. Reason: Solved

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Conditinal statements?

    Hi Gigaworks,

    In F9 try the following formula:

    =SUMPRODUCT(--($A$2:$A$16=$E9),--($C$2:$C$16=RIGHT(F$7,1)+0))

    Copy that to the right and down. In your spreadsheet make sure the values in column A match EXACTLY the values in column E (some of yours don't, for example there is a space after all of the "Room 3" entries in column A, but no space where it says "Room 3" in E11).

    The second part of the formula looks at the last character in row 7 (1, 2, 3 or 4) to match it against the code in column C. This may need to be adjusted for your not-as-simplistic real dataset.

+ 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