+ Reply to Thread
Results 1 to 3 of 3

Using a variable inside a range

  1. #1
    Registered User
    Join Date
    07-16-2019
    Location
    Florida
    MS-Off Ver
    Excel for Office 365 MSO (16.0.10730.20348) 32-bit
    Posts
    2

    Using a variable inside a range

    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 for reading!

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    UK
    MS-Off Ver
    2010 primarily
    Posts
    3,044

    Re: Using a variable inside a range

    I'd suggest you use two named cells. Then you can simply set the output cell to either Range("PlayerA") or Range("PlayerB"), and then increment that appropriately.
    Rory
    Days when we raged, we flew off the page
    Such damage was done

  3. #3
    Registered User
    Join Date
    07-16-2019
    Location
    Florida
    MS-Off Ver
    Excel for Office 365 MSO (16.0.10730.20348) 32-bit
    Posts
    2

    Re: Using a variable inside a range

    Thanks Rory!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1