working out combinations of words from a list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list of 33 words. From this list I need to work out the amount of
combinations of 2 words that can be made from the list of 33 words. I then
need to create a listing of what the combinations actually are.

I know that this is very complicated as I have already worked out that there
are 528 possible combinations but I need a way of actually creating the list
of the combinations.
 
Is there a practical reason for doing this, or is this a homework question?
 
Hi Mark,

have a look at this one:

Sub Test4566()
' you need a blank doc
Dim oPrg1 As Paragraph
Dim oPrg2 As Paragraph
Dim Str1 As String
Dim Str2 As String

Dim l As Long
' create Pseudo-Words
ActiveDocument.Range.Delete
For l = 1 To 33
Selection.TypeText Format(l, "0000") & vbCrLf
Next
'delete last paragraph, which is empty
ActiveDocument.Paragraphs.Last.Range.Delete
ReDim myarray(1 To 33 * 33) As String ' 1089 not 528
l = 0
For Each oPrg1 In ActiveDocument.Paragraphs
Str1 = Left(oPrg1.Range.Text, 4)
For Each oPrg2 In ActiveDocument.Paragraphs
Str2 = Left(oPrg2.Range.Text, 4)
l = l + 1
myarray(l) = Str1 & "-" & Str2
Next
Next
ActiveDocument.Range.Delete
For l = 1 To UBound(myarray)
Selection.TypeText myarray(l) & vbCrLf
Next
ActiveDocument.Paragraphs.Last.Range.Delete

End Sub

Have some fun tonight.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top