Looping

  • Thread starter Thread starter scottwilsonx
  • Start date Start date
S

scottwilsonx

I have a worksheet that simulates dealing cards, and calculates th
number of times you could expect to get a king, queen or ace.

What I want is to graph the results as the macro runs.
I know I want a loop function, but cant get my head round it!

For information,
The range i want to graph is: A1:A40 and C1:C40 where row 1 has th
header: "queen" and "king" on A and C respectively .

I would like cell P1 to include the number of deals I want to produce
ie: the number of times it should loop.

Any ideas on how I should construct the code - my attempts have bee
unsuccessful Im afraid.

Thanks
Scott
 
How about:
Sub Test()

Dim lngCounter As Long
Dim lngColACounter As Long
Dim lngColCCounter As Long
Dim lngTotal As Long

lngTotal = Range("P1").Value
lngColACounter = 2
lngColCCounter = 2

For lngCounter = 1 To lngTotal
'Generate your random card.
'if the card is a queen then.
'Range("A" & lngColACounter).Value = 1
'lngColACounter = lngColACounter + 1
'End If
'if the card is a king then.
'Range("C" & lngColACounter).Value = 1
'lngColCCounter = lngColCCounter + 1
'End If
Next lngCounter

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

Back
Top