View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default a problem in generating a list of all of the possible combinations of those words

Dim rng1 as Range, rng2 as Range, rng3 as Range
Dim cell1 as Range, cell2 as Range, cell3 as Range
Dim rw as Long

With Worksheets("Sheet1")
set rng1 = .Range(.cells(1,1),.cells(1,1).End(xldown))
set rng2 = .Range(.cells(1,2),.cells(1,2).end(xldown))
set rng3 = .Range(.cells(1,3),.cells(1,3).End(xldown))
End With
rw = 0
with Worksheets("Sheet2")
for each cell1 in rng1
for each cell2 in rng2
for each cell3 in rng 3
rw = rw + 1
.Cells(rw,1).Value = cell1 & " " & cell2 & " " & cell3
Next
Next
Next
End With

This does no checking for going beyond the end of the worksheet, so you
would need to add type of code if your lists get big enough to cause that.

--
Regards,
Tom Ogilvy

"chipper" wrote in message
om...
Hope this is the right place for this - I've kinda hit a brick wall
with this one and was hoping that one of you guys could point me in
the right direction;

I have a 3 columns of words headed up as type, colour, sound
The number of words (rows) varies can be 5 can be 20, I add a new set
of 3 words by just tagging them at the bottom of the column.

No sorting is needed but I need to be able to generate, perhaps on
another sheet, a list of all of the possible combinations of those
words. So I guess Im saying that I have a matrix that grows and I
would like to press a button and see the permutations listed
underneath each other on a separate sheet - ideally with a space
between each set. I hope this makes some kinda sense <smile

Thanks in advance to anyone who can help, kind regards Michael