PDA

View Full Version : Solved: grouping?



dvenn
07-11-2006, 08:37 AM
no idea where to begin really but here's a shot...

I have a sheet with some data in it...

in A8:A38 I have some unique IDs, then in D29-D51 I have some grouping IDs

For each Group ID in D29-D51 I need to create a row containing the unique ID, group ID and some additonal information from cells B2:B4 & E29:F51

the data should be as follows (comma sep'ed for example). Example assumes there are two unique ID's existing in A8:A9 and two group IDs existing in D29-D30..

A8,E29,B2,B3,B4,D29 & " (" & F29 & ")"
A9,E29,B2,B3,B4,D29 & " (" & F29 & ")"
A8,E30,B2,B3,B4,D30 & " (" & F30 & ")"
A9,E30,B2,B3,B4,D30 & " (" & F30 & ")"

and so on .. (if more existed)

I would prefer macro versus formula (this could potentially get very large with a whole bunch of fomulas).

Thanks in advance for any assistance.

FYI, I have no problems realigning the data on the sheet to facilitate this objective so if it would work better with a different arrangement, please advise

dvenn

mdmackillop
07-11-2006, 08:45 AM
Hi Daniel,
Can you post a sample with dummy data and maybe an "expected" outcome It saves us having to create one to test a macro.
Regards
MD

dvenn
07-11-2006, 09:06 AM
Here is an example workbook.

The ABAY tab contains all the necessary data.. The output tab is what I would like ti to look like when done.. the button (obviously) would be the trigger

mdmackillop
07-11-2006, 02:04 PM
I'm not sure if incrementing dates is correct, but for the rest, try

Option Explicit
Sub Listing()
Dim i As Long, j As Long, k As Long, d As Long
k = 1: d = 0
With Sheets("Output")
For i = 29 To [D29].End(xlDown).Row
For j = 8 To [A8].End(xlDown).Row
.Cells(k, 1) = Cells(j, 1)
.Cells(k, 2) = Cells(i, 5)
.Cells(k, 3) = Cells(2, 2) + d
.Cells(k, 4) = Cells(3, 2)
.Cells(k, 5) = Cells(i, 4) & " - (" & Cells(i, 6) & ")"
k = k + 1
Next
'Increment date
d = d + 1
Next
End With
End Sub

dvenn
07-12-2006, 08:04 AM
Exactly what I was looking for... Thanks..