Using a variable inside a range

SparkyFL

New Member
Joined
Jul 16, 2019
Messages
1
[FONT=&quot]VBA newbie here. I am trying to create a tool for keeping stats for my son’s basketball team. In simple terms, this is what I want to create: Three buttons - Player A, Player B, Two Pointer. When Player A scores, I click the Player A button then the Two Pointer button. In my (inexperienced) mind, the logic goes like this: When the Player A button is clicked, that sets the variable CurrentPlayer to Player A; then when the Two Pointer button is clicked, a cell dedicated to Player A’s points total is incremented by 2. I am getting stuck on the Two Pointer button, because I don’t know how to use the CurrentPlayer variable to increment the correct cell by 2. What I am trying to avoid is having a Two Pointer button for each player, because as you can imagine that gets unwieldy when we add in 3 pointers, free throws, steals, assists, blocks, etc. Thanks![/FONT]
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You could do this without any buttons but simply by double clicking the player's name (assuming you have a list of player names in a column). When you double click on a name, a user form would pop up where you can select any one of two pointer, 3 pointer, free throw, steal, assist or block and have the appropriate totals incremented. If this approach would work for you, perhaps you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do using a few examples from your data and referring to specific cells, rows, columns and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
I like mumps concept. As a possible enhancement, I might suggest right clicking the name instead of double clicking. Then the option list would come up in a context menu, and a left click would select it. Two clicks, very fast. If you organize the sheet with a column of names, you could have the next several columns be points, assists, blocks, steals, fouls, etc. All of those stats would be updated and visible in real time. Then go a few more columns over and have the same thing for the visiting team.

Here's an example of how to do that:

https://www.mrexcel.com/forum/excel...create-multiple-macros.html?highlight=context

See post # 9.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top