ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping (https://www.excelbanter.com/excel-programming/312530-looping.html)

scottwilsonx[_52_]

Looping
 

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


Geof

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

.



All times are GMT +1. The time now is 09:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com