JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
I have a workbook that I use to track wins and losses in a game of solitaire. On the main sheet, I have a Score Button control that calls a sub that tracks the results and updates a number of statistics on that sheet.
I'd like to add a second sheet with columns for keeping track of the number of moves used for each win and loss. This minisheet shows an example of the ranges in question. The Moves column lists the number of moves it took to complete the game. In the real sheet, it goes to 400. The Wins and Losses columns record how many games took that many moves to complete. For example, of the games that took 9 moves to complete, there were 4 wins and 11 losses.
I want to add code to my Score sub that will look up the number of moves in the Moves column and increment the tally in either the Wins or Losses. I need help with the code that, given the number of moves and whether it was a win or a loss, will increment the correct number. For example, if I get a win in 10 moves, the sub will increment C15 from 3 to 4.
To make these ranges easy for the sub to access, I have given them each a global name. The minisheet doesn't show the range names, so here's a screen shot of the Name Manager.
Thanks
I'd like to add a second sheet with columns for keeping track of the number of moves used for each win and loss. This minisheet shows an example of the ranges in question. The Moves column lists the number of moves it took to complete the game. In the real sheet, it goes to 400. The Wins and Losses columns record how many games took that many moves to complete. For example, of the games that took 9 moves to complete, there were 4 wins and 11 losses.
Temp.xlsx | |||||
---|---|---|---|---|---|
B | C | D | |||
5 | Moves | Wins | Losses | ||
6 | 1 | 0 | 1 | ||
7 | 2 | 1 | 3 | ||
8 | 3 | 0 | 8 | ||
9 | 4 | 3 | 7 | ||
10 | 5 | 5 | 11 | ||
11 | 6 | 9 | 16 | ||
12 | 7 | 6 | 13 | ||
13 | 8 | 7 | 14 | ||
14 | 9 | 4 | 11 | ||
15 | 10 | 3 | 9 | ||
16 | 11 | 0 | 3 | ||
17 | 12 | 2 | 5 | ||
Sheet1 |
I want to add code to my Score sub that will look up the number of moves in the Moves column and increment the tally in either the Wins or Losses. I need help with the code that, given the number of moves and whether it was a win or a loss, will increment the correct number. For example, if I get a win in 10 moves, the sub will increment C15 from 3 to 4.
To make these ranges easy for the sub to access, I have given them each a global name. The minisheet doesn't show the range names, so here's a screen shot of the Name Manager.
Thanks