make a sentence from words chosen at random

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?
 
Z

zantor

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
 

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

Top