Excel Example.xlsxHello guys, I am relatively new to VBA (and the forum) and I was wondering if someone could offer some advice on a macro to group together cells based on information in a different column. I attached an example of what I need done. The information is on Sheet1 of the workbook, and I'd like the macro to group together document names (column D) based on their document ID (Column C). I'd like to have all the document names that correspond to one document ID in a list format in one cell next to their document ID's placed in row H. Pivot tables are out of the question as I have 1000's of rows of data, and the document names for a specific ID need to go in a list in one cell. Any ideas on what macro to use would be greatly appreciated.
Last edited by kingfishmike; 02-10-2012 at 10:11 AM.
Try this
Sub Test() For N = 2 To Cells(Rows.Count, 1).End(xlUp).Row + 1 If Cells(N, 1) <> Cells(N - 1, 1) And N <> 2 Then GrowingString = GrowingString & Cells(N - 1, 2) Cells(Rows.Count, 8).End(xlUp).Offset(1, 0) = Cells(N - 1, 1) Cells(Rows.Count, 8).End(xlUp).Offset(0, 1) = GrowingString GrowingString = "" ElseIf N <> 2 Then GrowingString = GrowingString & Cells(N - 1, 2) & Chr$(10) End If Next N End Sub
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.
mrice, thanks for the help, but so far, it is only grouping a list of the items in the "state" column in a different column. I need the document names grouped along side the document numbers they represent
Nevermind mrice, I tweaked it a little and got it to work. You are the man! Thanks alot
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks