LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default creating variables


I've written a small spreadsheet to keep track of a game that some
co-workers play.

At one point, when the spreadsheet is scoring, I need it to give me a
list of winners for that round. There are 11 people playing, so I
dimensioned 11 variables, "win1", "win2",..."win11" for the scoring
macro. When someone wins (and all 11 can win each round), the
variable "win1" will be assigned to the first winner's name, the
second to "win2" etc. I dimensioned 11 in case all 11 win.
It then prints to the screen a list of winners using msgbox.

My problem is, next year, we might have more or less than 11 players.
I want to be able to give the spreadsheet to anyone to use. They wont
be able to go in and change the code.

Is there a way to have any number of variables dimensioned to
accomodate any number of contestants?

Here are some pieces of the macro that scores.

Dim win1 As String
Dim win2 As String
Dim win3 As String
Dim win4 As String
Dim win5 As String
Dim win6 As String
Dim win7 As String
Dim win8 As String
Dim win9 As String
Dim win10 As String
Dim win11 As String


Count = Count + 1
If Count = 1 Then win1 = Cells(1, c.Column).Value
If Count = 2 Then win2 = Cells(1, c.Column).Value
If Count = 3 Then win3 = Cells(1, c.Column).Value
If Count = 4 Then win4 = Cells(1, c.Column).Value
If Count = 5 Then win5 = Cells(1, c.Column).Value
If Count = 6 Then win6 = Cells(1, c.Column).Value
If Count = 7 Then win7 = Cells(1, c.Column).Value
If Count = 8 Then win8 = Cells(1, c.Column).Value
If Count = 9 Then win9 = Cells(1, c.Column).Value
If Count = 10 Then win10 = Cells(1, c.Column).Value
If Count = 11 Then win11 = Cells(1, c.Column).Value

If Count 1 Then MsgBox Count & " contestants scored - " & win1 &
win2 & win3 & win4 & win5 & win6 & win7 & win8 & win9 & win10 & win11

If Count = 1 Then MsgBox Count & " contestant scored - " & win1 & win2
& win3 & win4 & win5 & win6 & win7 & win8 & win9 & win10 & win11

If Count = 0 Then MsgBox "nobody scored."

All of their names are on the first sheet in the workbook. I have a
cell that counts the contestants (A2).

Next year, if there are 15 contestants, I don't want to have to go
back and add more lines of code.

thanks for your help in advance.
JasonK


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Variables Programmically Brite Excel Discussion (Misc queries) 5 April 23rd 07 10:34 AM
Creating dummy variables in Excel Alok Excel Worksheet Functions 0 November 30th 06 05:46 PM
Creating dummy variables in Excel ALEX Excel Worksheet Functions 0 November 30th 06 03:30 PM
Creating a formula that will SUM with 2 Variables B Akers Excel Worksheet Functions 2 March 28th 06 06:34 AM
Creating sequential variables on the fly ForestRamsey Excel Programming 3 November 16th 05 08:11 AM


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"