I have a worksheet where i want to take all the pick tickets for a p.o and dump them into one cell with a comma separating each of them. I could use an AND formula, but the worksheet is a living document that changes daily and it will be used by someone who's not excel savvy. And more importantly, I want as much of the worksheet as possible to update on its own.
I need a formula in the cell to say "Dump all the pick tickets for a p.o into this cell and separate them with a comma"
I should also note that all of the pick tickets are going down the sheet in case that makes a difference.
I feel like it would be a vlookup and an array formula, but I cannot figure it out.
I've attached an example of what i want it to do. There's 3 tabs, the raw data which is what my pivot table will pull from, the Before Pivot which will show how it currently looks because I can't figure out the formula, and the After Pivot which will show what I want the end result to look like.
Last edited by juniperjacobs; 09-18-2010 at 11:37 AM. Reason: spelling error in header
Try this user defined function
Paste this into a new VBA module (ALT F11 then Insert - Module) and then add the the sheet like a normal function.Function CommaList(SourceRange As Range) As String Dim Cell As Range For Each Cell In SourceRange If Cell.Value <> "" Then CommaList = CommaList & Cell.Value & "," End If Next Cell If Len(CommaList) > 0 Then CommaList = Left(CommaList, Len(CommaList) - 1) End Function
e.g. =CommaList(B2:B8)
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
or
Function listing(c0 As Range) listing = Join(Application.Transpose(c0), ",") End Function
If you're saying the values in raw data are ordered by PO# (implied by sample) then:
Revise the PT source to include column E and use this in your Pivot (rather than C).'Raw Data'!C2 =IF(COUNTIF($A$2:$A2,$A2)=1,$B2,INDEX($C$1:$C1,MATCH($A2,$A$2:$A2))&","&$B2) copied down 'Raw Data'!E1: Bucket [ie header value] 'Raw Data'!E2: =LOOKUP($A2,$A$2:$C$20) copied down
The above means all is formula driven and dynamic though I would reiterate the above is based on assumption that data is sorted by PO#
(ie utilises binary search for optimisation)
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
i'm not vba fluent, i just made my first one a few wks ago and all it was was a code to get rid of zeros in a pivot table (i hate the roundabout way 2007 gets rid of zeros). can you explain?
Donkey-
Yours kind of makes sense but I can't get it to work. A. How do i run it once it's in there and B, it's giving me a compile error on each line of formula.
Donkey, also, it seems like what you sent is dependant on the Pick Ticket bucket, but that bucket is where the formula will be entered, the way I listed it in the example is what the final result should look like. In other words, in the actual file, that column is blank and I want all the pick tickets to pull into it.
also, and this will sound stupid, once you create a module, how do you access it?
I'm not quite sure what you mean by a Compile Error (that's a VBA term) but based on your locale of US the suggestions should work without issue.
Not so. The formulae when entered in the cells designated will generate the requested results - attached.Originally Posted by juniperjacobs
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Donkey, your first formula: =IF(COUNTIF($A$2:$A2,$A2)=1,$B2,INDEX($C$1:$C1,MATCH($A2,$A$2:$A2))&","&$B2)
actually works just pasted in a cell for the most part, except that the first cell in the pick ticket bucket column next to the first pick ticket within the p.o range doesn't gather all the pick tickets for that p.o, instead the cell in the pick ticket column next to the last pick ticket in the range gathers all the pick tickets within the range. how do we get the cell next to the first pick ticket within the p.o range to gather all the pick tickets?
I had presumed that by adding a working example with PT output the below would all be rather transparent, seemingly not.
As mentioned in my first post - the "final" ticket bundle for the given PO is generated in Column E not Column C and the Pivot uses the new column as source (not Col C).
Col C in this approach acts as a "running count" string - nothing more (it is not the final output as used in the Pivot)
That is to say the string extends with each PO transaction as a new ticket is added to the bundle.
Col E subsequently references the last "running count" string in Col C for the given PO thereby ensuring that all transactions for any given PO use the final complete ticket bundle string for that PO.
Given Col E now holds the final bundle string for the PO we use this in the Pivot.
The reason we use 2 columns [Col C & E] for this formula driven approach is efficiency.
Last edited by DonkeyOte; 09-04-2010 at 01:42 PM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Donkey, I am so sorry, I didn't look at your formula in column C, yes you've answered my question beautifully. Forgive me, I'm new to the forum and still working out the kinks.
thank you SO, SO Much!
Genius!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks