Thread: Looping
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Geof Geof is offline
external usenet poster
 
Posts: 11
Default Looping

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
-----Original Message-----

I have a worksheet that simulates dealing cards, and

calculates the
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 the
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 been
unsuccessful Im afraid.

Thanks
Scott.


--
scottwilsonx
----------------------------------------------------------

--------------
scottwilsonx's Profile:

http://www.excelforum.com/member.php?
action=getinfo&userid=11128
View this thread:

http://www.excelforum.com/showthread...hreadid=266462

.