+ Reply to Thread
Results 1 to 10 of 10

Adding specific values

  1. #1
    Registered User
    Join Date
    07-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    58

    Adding specific values

    Hi guys. I have managed to get my data mainly numerical, but for a couple of cells I need some text. This doesnt work with pivot tables, so I thought I would try and extract the numbers. So I have a cell which contains the data

    7 pax 2 cars @ 12.05
    2 pax 1 car @13.45

    So the cell has a line break and contains 2 lines. I essentially need to add the first number of each line, allowing for more lines to be added. So I have this to get the first number from the first line
    Please Login or Register  to view this content.
    I then have this formula which tells me how many lines there are
    Please Login or Register  to view this content.
    Is there anyway I could maybe combine the two to add the first number of every line? So for the above, it should be 7+2 so return 9.

    Thanks

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Adding specific values

    I may have used a sledge hammer to drive a finishing nail, but try this based on the two samples you offered...

    =(LEFT(A1,FIND(" ",A1)-1)+RIGHT(LEFT(A1,FIND("|",SUBSTITUTE(A1," ","|",3))-1),FIND(" ",LEFT(A1,FIND("|",SUBSTITUTE(A1," ","|",3))))))+0
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    07-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: Adding specific values

    Kool, that seems to work perfectly. That seems to work for 2 lines, say if I had 3 and I needed to extend the formula, is it a case of just duplicating the find part? Going through it now so I can fully understand it.

    Cheers

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Adding specific values

    Glad the help has gotten you this far...you're welcome and thanks for the feedback.

    The trick seems to be distinguishing the blanks that separate the different sections within the formula.

    I probably would need to see what you call a "3 line", but using Evaluate Formula would help you see and hopefully understand what the formula is doing.

    Evaluate Formula
    • Click on the cell with the formula >> Ribbon >> Formulas >> Formula Auditing >> Evaluate Formula

    You could also consider Text to Columns with using the "space" as the delimiter...

    Text to Columns
    • Highlight range to convert
    • Data >> Data Tools >> Text to Columns >> Check Delimited >> Next
    • Check Space >> Next
    • Click on the second column >> toggle Do not import column (skip) >> Repeat on the fourth, fifth, and sixth columns
    • Finish

    Now all you will be left with is the 7 in one column and the 2 in the other. Now just use =A1+B1

  5. #5
    Registered User
    Join Date
    07-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: Adding specific values

    Hey, I have just noticed a little problem. That formula counts the 2 numbers on the first line. What I am trying to do is count the first number on the first line, and the first number on the second line. So if its

    7(this number) pax 4 cars @ 12.05
    2(+ this number) pax 1 car @ 13.45

    The above would be 7+2 = 9

    Is that possible?

    Cheers

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Adding specific values

    How about...

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: Adding specific values

    Ah, I see where you are heading. So you are finding the first space and then going to the character before this. The only problem with the formula is that it presumes the two lines are in two separate cells. Because I am working in a table format, the two lines are in the same cell. So I essentially need the first part to refer to A1 line 1, and the second part to refer to A1 line 2.

    Cheers

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Adding specific values

    On the second line, the 2 pax, could it ever be more than 9?

    Essentially we can look for Char(10) which is a line feed. The same thing as pressing Alt + Enter at the end of the first line.

    Tell me how this works out for starters...

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Sorry I misinterpreted this from the beginning...

  9. #9
    Registered User
    Join Date
    07-11-2013
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    58

    Re: Adding specific values

    I have been using Alt + Enter to create new lines and your formula works perfectly!! If only I could give you more rep!!! Thanks for the help, I have learned a lot. Will mark this thread as solved now, thanks.

    Nick

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Adding specific values

    Could something like this suit your problem?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 06-28-2012, 07:08 AM
  2. Adding specific values from an ever changing list in Excel.
    By Opt1kal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2011, 01:04 PM
  3. adding values to a combobox from a specific range of cells
    By blindzero678 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 08-05-2010, 07:02 PM
  4. Excel 2007 : Adding Specific Values in a Table
    By aram87 in forum Excel General
    Replies: 3
    Last Post: 02-10-2010, 05:05 PM
  5. Adding $ Values for multiple categories to specific employees
    By aaron34714 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-17-2008, 01:20 AM

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