+ Reply to Thread
Results 1 to 9 of 9

Multiple terms in same cell?

  1. #1
    Registered User
    Join Date
    04-24-2008
    Posts
    6

    Multiple terms in same cell?

    Hello,

    I am wondering if it is possible to enter two or more summable terms in the same cell. For example, if I entered "3A + 2B" in a cell, I would like Excel to be able to sum these two terms as "5", but still be able to retrieve information about how many "A"s and "B"s there are in the cell. Does anyone know of a way to do this? Glad to clarify if needed.

    Matthew
    Last edited by shg; 04-24-2008 at 01:36 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You can enter =3*A + 2*B, and define A and B as constants both equal to 1: Insert > Name > Define, A Refers to: =1

    What are you trying to do and why?

  3. #3
    Registered User
    Join Date
    04-24-2008
    Posts
    6
    I'm trying to avoid putting too many columns in a file I'm working on. By the way, I should have mentioned that I'm using 2007.

    Your suggestion worked (although, in Excel 2007, the "Define Name" command is in the "Formulas" tab), but I would also like to be able to sum only the terms that I choose; i.e., only the number of "A"s, "B"s or other terms. Is there any way to use the sum function (or another function) to do this?

    Thanks

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I've lost the bubble on what you're trying to do and why.

    The numbers of A's in a string is =len(a1) - len(substitute(a1, "A", ""))

    You could assign names (A, B, ...) to cells and change the values to count only the terms you want.
    Last edited by shg; 04-25-2008 at 08:09 PM.

  5. #5
    Registered User
    Join Date
    04-24-2008
    Posts
    6
    Quote Originally Posted by shg
    I've lost the bubble on what you're trying to do and why.
    I am collecting data for certain categories of services. Many of these categories can be divided up into smaller subcategories, but I would like to avoid having to make separate columns for each subcategory. Instead, I want to assign the subcategories values of "A", "B" etc., and enter them into a single cell for each service date (thus: 5*A + 6*B + ... for any given date). You have shown me how to do this, but now I would like to know how to track the sum of the categories and subcategories as needed.

    For example, given 5*A + 6*B in one cell and 6*A + 7*B in another cell, I want to be able to sum only the terms with A (giving 11) or only those with B (giving 12). The regular sum function recognizes only the total in each cell, as far as I can see.

    Does that help to clarify?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    So back to my prior suggestion: Create named cells, A, B, C, ...

    Set the values of the cells you want to count to 1, and those you don't to zero.

    BTW, I'd recommend against doing what you're doing.
    Last edited by shg; 04-28-2008 at 09:11 PM.

  7. #7
    Registered User
    Join Date
    04-24-2008
    Posts
    6
    Quote Originally Posted by shg
    So back to my prior suggestion: Create named cells, A, B, C, ...

    Set the values of the cells you want to count to 1, and those you don't to zero.

    BTW, I'd recommend against doing what you're doing.
    Sorry, I'm having trouble understanding. If the cells A, B, C, ... are equivalent to my subcategories, then, there is no cell I don't want to count; what I want is to count different cells in different cases. Please let me know if I'm missing something.

    Also, out of curiosity, why don't you recommend what I'm trying to do?

  8. #8
    Registered User
    Join Date
    04-24-2008
    Posts
    6
    Maybe I do understand now. If I let A = 1 and B = 0, I can sum only the As, but, if I want to record the sum, I have to store it as a constant rather than as a function. If I don't, then, when I change the values of A and/or B, the function will return a different value and the earlier value will be lost.

    Is this correct? I may not have all the terminology right, since I am far from an Excel expert.
    Last edited by ml20080424; 04-30-2008 at 03:03 PM.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    ... why don't you recommend what I'm trying to do?
    Because Excel has enormous capabilities to process data, most of which are oriented to the existence of atomic data in cells. You're trying to implement a custom parsing method that extracts multiple data from a single cell, for reasons that are not at all clear. It's not impossible, but neither is it simple, and there are almost certainly easier and straightforward alternatives.

+ 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