+ Reply to Thread
Results 1 to 11 of 11

assigning numeric value to a string of texts

  1. #1
    Registered User
    Join Date
    04-26-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    10

    assigning numeric value to a string of texts

    okay this one essentially is a follow up to my last thread but I'll give a brief overview to see if it makes sense

    I'm making a spreadsheet that totals the number of hours a person participated in.

    different events equate into a different number of hours served

    names are listed in column A
    Total number of hours are listed in column B
    and the events the individual participated in are listed in column C

    Column C contains a drop down menu listing the events I'll use states as an example Texas, New York, Washington, California, ect... where multiple selections are possible

    the data list for the events is listed in column E,
    and the amount of time each corresponding event represents is in column F, i.e.
    Texas-1
    New York-3
    Washington- 4
    California- 4

    How do I setup the cells in Column B to add up the total that would be listed in the adjacent cell in Column C I.E.

    Cell C4 contains: Texas, New York, California
    how can I get cell B4 to calculate =1+3+4

    thanks

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: asigning numeric value to a string of texts

    Could you post a sample workbook with your expected results?

    Thank You
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: asigning numeric value to a string of texts

    How do I setup the cells in Column B to add up the total that would be listed in the adjacent cell in Column C I.E.

    Cell C4 contains: Texas, New York, California
    how can I get cell B4 to calculate =1+3+4
    The first order of business is to properly structure your worksheet in an efficient design that facilitates data extraction and analysis. See this link for help on setting a correctly structured worksheet: Excel Best Practice & Design

    By letting cell C4 hold several joined text strings, you make the problem of matching and extracting numeric data from column-E much more difficult. Moreover, column-E should only contain text (i.e.,Texas and not Texas-1) and the adjacent column should contain the numbers.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    04-26-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: asigning numeric value to a string of texts

    Quote Originally Posted by Palmetto View Post
    The first order of business is to properly structure your worksheet in an efficient design that facilitates data extraction and analysis. See this link for help on setting a correctly structured worksheet: Excel Best Practice & Design

    By letting cell C4 hold several joined text strings, you make the problem of matching and extracting numeric data from column-E much more difficult. Moreover, column-E should only contain text (i.e.,Texas and not Texas-1) and the adjacent column should contain the numbers.

    Column E does only contain text i just put it as Texas-1 to give a visual. column I would have the numbers

    Also I agree that having column C hold multiple strings of text is probably not very efficient. However it is what I have to work with

  5. #5
    Registered User
    Join Date
    04-26-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: assigning numeric value to a string of texts

    I attached a sample workbook

    Column C contains the multiple select drop down from the data range in column G

    once selected I need the cells in column B to add the total value of text strings selected (value as indicated in column H)
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: assigning numeric value to a string of texts

    That is different then your description....

    Try in B2:

    =IF(C2="","",VLOOKUP(C2,$G$2:$H$8,2,0))

    copied down.

    To sum all =SUM(B2:B6)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: assigning numeric value to a string of texts

    In B2 put this array formula:
    =IF(C2="","",SUM(ISNUMBER(SEARCH($G$2:$G$8,C2))*($H$2:$H$8)))

    ...confirmed by pressing CTRL-SHIFT-ENTER. Curly braces { } will appear around the formula to indicate the array is active. Then copy that cell down column B through B6.

    As you add multiple choices in column C, the sums will total in B properly.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: assigning numeric value to a string of texts

    How is that any better than a simple Vlookup or am I missing something?

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: assigning numeric value to a string of texts

    I hadn't seen your answer nor tested it yet. Now that I have, no, it doesn't work unless he only makes one choice in C2. As soon as he makes a second choice it breaks. That's why I used an array.

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: assigning numeric value to a string of texts

    I see.. I hadn't enabled macros.. so didn't realize there were multiple selections in one cell possible...

    .. my apologies.

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: assigning numeric value to a string of texts

    Another non CTRL+SHIFT+ENTER way would be...

    =IF(C2="","",SUM(SUMPRODUCT(--(ISNUMBER(SEARCH($G$2:$G$8,C2))),$H$2:$H$8)))

    and we are assuming you can't pick same city twice.. or if you do it will be accounted for once only.
    Last edited by NBVC; 05-05-2010 at 04:05 PM.

+ 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