Using a variable inside a range


New Member
Jul 16, 2019
[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]

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result


Well-known Member
Apr 11, 2012
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 or 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.

Eric W

MrExcel MVP
Aug 18, 2015
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:

See post # 9.

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics