VBA to create new data help please
does this code:
Sub kombin()
Dim counter as Integer
For j =1 to Range("A1:A3").Cells.Count
For k =1 to Range("B1:B3").Cells.Count
For m =1 to Range("C1:C3").Cells.Count
For n =1 to Range("D1:D3").Cells.Count
counter = counter + 1
Cells(Counter+6,1)=Cells(1,j)
Cells(Counter+6,2)=Cells(1,k)
Cells(Counter+6,3)=Cells(1,m)
Cells(Counter+6,4)=Cells(1,n)
Next n
Next m
Next k
Next j
End Sub
do what you're up to?
adjust your ranges to suit
On 9 Kwi, 11:08, Andy wrote:
I have 4 different sets of datalists currently.
Dataset A, with values A1, A2, A3,....
Dataset B, with values B1, B2, B3,.....
Dataset C, with values C1, C2, C3,.....
Dataset D, with values D1, D2, D3,.....
What I need to do is 'merge' them all together to create a 4 column list
with each possible combination.
i.e.
A1,B1,C1,D1
A1,B2,C1,D2....
A1,B1,C2,D1
A1,B1,C2,D2.... etc
I may not have explained this very well and am not that good with VBA so any
help at all, appreciated please. Happy to try and explain further!
Many thanks
|