+ Reply to Thread
Results 1 to 10 of 10

Collating data in several columns

  1. #1
    Registered User
    Join Date
    12-12-2008
    Location
    Cardiff
    Posts
    4

    Collating data in several columns

    Hi there,

    I have been working with Excel in different formats for several years but can't seem to find a short hand way of carrying out a long hand task.

    Basically I have to compile some figures from various different teams, the data comes in a standard way however although the codes used by different teams vary, they are all from the same standard list. I copy paste all the information into one sheet but then need to summarise it. The copy paste into the sheet looks something like this: (though there is usually a larger amount of data.

    A B C D E F G H
    1 Jan Feb Mar Apr
    2 CC01 12 CC01 23 CC03 82 CC02 20
    3 CC02 46 CC04 14 CC04 15 CC03 04
    4 CC07 52 CC05 26 CC06 12 CC06 01
    5 CC08 22 CC08 19 CC07 08 CC08 11

    I need it to look somthing like this: (Apologies for the not quite exact formatting.

    A B C D E F
    1 Code Jan Feb Mar Apr Total
    2 CC01 12 23 0 0 35
    3 CC02 46 0 0 20 66
    4 CC03 0 0 82 04 86
    5 CC04 0 14 15 0 29
    6 CC05 0 26 0 0 26
    7 CC06 0 0 12 01 13
    8 CC07 52 0 08 0 60
    9 CC08 22 19 0 11 52

    I know how to total the rows automatically, its a case of sifting through the data to get a difinitive list of all codes used.

    Any help would be grately appreciated.

    Many thanks

    C

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Since the data breaks down into identifiable pairs of data, you can do a VLOOKUP on each subset. Here is a sample using a VLOOKUP for each Month's two column pair.

    Just adjust the ranges to your actual data and drag down, it will reorder the data into the desired format. You just need to put in the Month headers and CC01>>CC08 row labels.
    Attached Files Attached Files
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    12-12-2008
    Location
    Cardiff
    Posts
    4
    Hi there,

    Thanks for the response it was useful and similar to what I had already done, however the difficulty lies in getting the codes to do the lookup with. As there can be up to 500 sometimes (my example was very much simplified).

    My method (longhand) has been to copy past all the codes from the different months into one column, do an alphabetical sort and then delete the duplicates by searching through row by row to get my definitive list. Is there a way of excel looking at the data and pulling off a list of codes that only occur once - getting my reference list for the vlookup?

    Thanks

    C

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Post up a real sample so we can see what we're up against.

  5. #5
    Registered User
    Join Date
    12-12-2008
    Location
    Cardiff
    Posts
    4
    Ok, have attached an example similar to the type of thing I need to work with.

    For me the difficulty is all about getting the list of team names that appear in all quarters so I can use a Vlookup on them to get the information to compare teams by quarter and put a zero in if there was no value returned. The latter part I can do, its just finding the easiest (quickest) way of getting the names.

    Hope you can help, and hope the example makes sense.

    Oh and I have Excel 2007 at home, but unfortunately on Excel 2003 in work, so if the solution is practical to work with 2003 I would be grateful.

    Thanks.

    PS. I know that once I have copypasted all team names from all quarters being referenced into one column the pivot table function will summarise them into a nice list, would prefer to just be able to select the table and get this information.
    Attached Files Attached Files
    Last edited by CardiffExcel; 12-13-2008 at 12:58 PM. Reason: forgot to add a bit...

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    There's a Excel Add-in called MOREFUNC, I've embedded into this sheet, gives you a bunch of other functions not normally in Excel. The one we're using is called UNIQUEVALUES, and buried inside an INDEX functions, will give you the list you want. But your resulting list is LONG, it's a lot of calculation, so I turned off AutoCalc in the sheet. Press F9 anytime you want this sheet to recalculate, or just turn it back on after you've copied your data onto the DATA sheet.

    The CHART sheet compiles your data after you copy onto the DATA sheet. The column that does the TEAM names uses a named range called "Teams" and will only return text values, it skips the numeric answers, just drag it down the A column until it stops giving answers. The formulas for row 2 on DATA all pull answers from a different subset of the DATA, so you need to set up the first row then copy that down. I've already done that, it's just important to realize if you expand the data set out to more columns in the future.

    Look it over. It's slow, but it works, and you can speed up things while your setting your data in by keeping the Tools > Options > Calculation > Manual setting active, then turn it back to Automatic.
    Attached Files Attached Files

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Nice work, JB.

    You could cut the calculation time in half by changing

    =IF(ISERROR(VLOOKUP($A2, Data!$A$2:$B$120, 2,FALSE)), 0, VLOOKUP($A2, Data!$A$2:$B$120, 2, FALSE))

    to

    =IFERROR(VLOOKUP($A2, Data!$A$2:$B$120, 2, FALSE)), 0)

    ... using either the native Excel 2007 IFERROR function, or this equivalent:
    Please Login or Register  to view this content.
    Also, for your UniqueTeams function, time for you to take a look at the Scripting.Dictionary object.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    I really hated the delay, and coerced some simpler code to do the work.

    If the data is this wide or smaller, just pressing the GetTeams button on this version and it will quickly build your chart.

    Thanks, SHG, I incorporated your UDF into this version as well so, IFERROR formulas are in effect. Reading? Oh my.... that would make things easier, right? Not sure I'm ready to start studying again, hehe.

    Hope this solves it for you, Cardiff. If you want to adjust the stuff it's doing in the GetTeams macro, it should be pretty straightforward. You can do it.
    Last edited by JBeaucaire; 12-13-2008 at 11:44 PM. Reason: Removed workbook, use the one from the next post.

  9. #9
    Registered User
    Join Date
    12-12-2008
    Location
    Cardiff
    Posts
    4
    Hey, thanks guys for the two responses, I will review tomorrow, as, at 00:45am at the moment, for me, its a little late to go through and understand your suggestions. Will do tomorrow as a matter of course, but wanted to thank the two of you for contributing solutions to my problem, many thanks!! Carlton

    :: Thanks should read overwhelmed....

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Understandable. I realized at church tonight that you might try running the macro twice over itself without resetting the chart, so I added another macro to make getting the chart ready to "run" again easy, this version has a "Reset Chart" button that clears the data that's there already.

    There's also an "AddFirstRowFormulas" macro you can use if you ever accidentally clear the base row(2) of formulas, since those are the ones needed to copy down.

    I'm off to bed now, myself. Cheers.

    This is totally Excel 2003 compatible, that's what I use.
    Attached Files Attached Files

+ 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