+ Reply to Thread
Results 1 to 11 of 11

Need to combine 2 rows of data into one line while summing their contents

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Need to combine 2 rows of data into one line while summing their contents

    Basically, we have 2 tablets tallying data and writing to the same .csv file. That csv file is then copied into a front page of a much larger excel worksheet where the tallied data is sorted and used for a variety of reasons. This works perfectly using index and match when only 1 tablet is being used, however, when both tablets are writing to the same csv at the same time it creates 2 lines instead of 1 line.

    For example 1 tablet might look like this:

    Lot 45689 4 6 8 9 1 5

    2 tablets looks like this:

    Lot 45689 2 3 1 8 1 4
    Lot 45689 2 3 7 1 0 1


    for the tallies, i would imagine a =SUMIF function might suffice, but that doesn't solve my problem of there being 2 lines with the same lot #.

    I am only dealing with this issue from the excel side, and have no control over the tablet functionality or the CSV file which further limits me.

    Any help would be greatly appreciated. Thanks!

    Wanted to add that the Lot #s change daily and often so with my understanding of pivot tables this rules them out as a viable option.
    Last edited by kyleh186; 07-01-2013 at 08:53 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Need to combine 2 rows of data into one line while summing their contents

    kyleh186, welcome to the forum. Can you please upload a small sample workbook (with anything confidential removed)? INDEX/MATCH will indeed only return the first match it finds, but multiple rows with the same Lot # shouldn't be a problem for SUMIF - that's what it's for.
    Brendan.


    __________________________________________________________________________________________________
    Things to consider:

    1) You can thank any poster by clicking the * at the left of a helpful post.
    2) You can help to keep the forum tidy by marking your thread as "Solved", if it has been answered to your satisfaction.
    3) Help us to help you, by uploading a sample workbook, showing the type of data you're dealing with, and clearly indicating what the results should be.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need to combine 2 rows of data into one line while summing their contents

    So once the tablets populate the data to the csv, you want a way to convert the 2 lines into 1 line?

    How much such lot numbers would there be in the file at one point of time? Just 1 set of many?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    07-01-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to combine 2 rows of data into one line while summing their contents

    I attached a very simplified version of the step that I am stuck on. There may be up to 50-60 different lots, and there will always be a duplicate of them IF they are using both tablets to count. However, there will also be times when they only use 1 tablet. This means any sumif formula is going to need to be adaptable to changing lot #s, and using anything spatially related is almost completely impossible.

    In my example the 1st tab is the raw data, the 2nd tab is the format I need it in to feed it into the larger excel file the way it is currently structured.
    Attached Files Attached Files

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Need to combine 2 rows of data into one line while summing their contents

    Using your spreadsheet this is the formula I wrote and it works.
    =SUMIF('How the CSV file looks'!$A:$A,'How I need the data formatted'!$A4,'How the CSV file looks'!B:B)
    It handles multiple versions of the lot # as well as single instances.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  6. #6
    Registered User
    Join Date
    07-01-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to combine 2 rows of data into one line while summing their contents

    That works perfectly for the tallied sizes, but it doesn't solve my problem of duplicate lot #s. Right now someone would have to manually type in each lot # to the 2nd worksheet otherwise there would be 2 instances of each lot # this time with their tallies being summed.

    Is there any formula I can put in column A of the 2nd worksheet that will take all of the Lot #s from column A of the first worksheet, eliminate the duplicates and only display them once each?


    Thank you

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Need to combine 2 rows of data into one line while summing their contents

    Ok, see what you need. The process i'd probably use is likely less "elegant" than others would use. I would likely use an advanced filter highlighting column A then copy to another location and check unique records only. THIS however will only let you copy them into the same worksheet. Then after doing that I'd cut and paste them into column A in the second worksheet then do the sumif after that.
    I'm sure there are more ways to do it that would involve fewer steps than mine. Maybe someone else can answer that one. Good luck and i'll watch for another reply.

  8. #8
    Registered User
    Join Date
    07-01-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to combine 2 rows of data into one line while summing their contents

    I was playing around with it and using the 'Remove Duplicates' tool is a workaround to an extent, because the rows are complete duplicates once they the sumif function has been used. I am more worried that I won't be the one using this spreadsheet though so I will have to show the user how to use the 'Remove Duplicates' tool. Automation is always better for that reason, as my confidence in the user is not so great. Id consider a macro except running a macro is probably going to be just as difficult for the user as using the 'Remove Duplicates' tool.

  9. #9
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Need to combine 2 rows of data into one line while summing their contents

    Ok, I found this formula in another post that may help. Here is the link...
    http://www.excelforum.com/excel-form...-quantity.html
    Fotis1991 posted it and it works (w/a minor change I made)
    Re: How to remove duplicates & add up the quantity?
    Another way is using this formula in another column(let's say E). So in E2 and copy down.

    =LOOKUP(REPT("Z",5),CHOOSE({1,2},"",INDEX(A$2:A$2741,MATCH(TRUE,INDEX(ISNA(MATCH(A$2:A$2741,E$1:E1,0)),0),0),1)))

    Then in your other column use a SUMIF function to add the numbers

    =SUMIF($A$2:$A$3000;E2;$B$2:$B$3000) copy down.
    <><><><><>
    I tested it out and it worked
    I'm not an "expert" at posting so I hope this doesn't violate any forum rules.
    Hope it helps.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to combine 2 rows of data into one line while summing their contents

    Do you want a macro(code) solution?
    Last edited by AB33; 07-02-2013 at 03:06 AM.

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

    Re: Need to combine 2 rows of data into one line while summing their contents

    If your CSV files are added together one after the other then something like this will work. If the calculation is no longer required once the data is on the How I need...page the data can be copied and paste special values in place to eliminate the formulae.
    Attached Files Attached Files
    <---------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)

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