make a sentence from words chosen at random

  • Thread starter Thread starter DL
  • Start date Start date
D

DL

A1:A10 contains prepositions

B1:B10 contains adjectives

C1:C10 contains nouns

D1:D10 contains verbs



Can I have a macro select one item at random from each range?
 
Hi DL,

This should help you:

Sub GenerateSentence()
Dim WordNumber As Integer
Dim Sentence As String
Dim c As Integer

For c = 1 To 4
Randomize
WordNumber = Int((10 * Rnd) + 1)
Sentence = Sentence & Cells(WordNumber, c) & " "
Next c

MsgBox Sentence

End Sub
 
Back
Top