Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 -- scottwilson ----------------------------------------------------------------------- scottwilsonx's Profile: http://www.excelforum.com/member.php...fo&userid=1112 View this thread: http://www.excelforum.com/showthread.php?threadid=26646 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Not Looping | Excel Discussion (Misc queries) | |||
Looping | Excel Discussion (Misc queries) | |||
Looping | Excel Programming | |||
looping to End | Excel Programming | |||
Looping | Excel Programming |