+ 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
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,428

    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
    I drink, and I know things

  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)

Similar Threads

  1. [SOLVED] Use an input variable inside a formula
    By fabien1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-27-2019, 07:26 PM
  2. [SOLVED] Can't assign range variable inside For loop
    By DMA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2017, 12:51 AM
  3. Refering to name with variable inside it
    By CobertRannon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-18-2013, 09:13 PM
  4. How to use variable inside Range?
    By amithreat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2010, 08:22 PM
  5. cell variable inside a url?
    By detlion1643 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-24-2009, 09:54 PM
  6. Concatenation of a variable inside a formula
    By ksmith99 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-14-2006, 04:14 PM
  7. [SOLVED] Using a range variable inside a excel function
    By Michael in forum Excel General
    Replies: 2
    Last Post: 11-14-2005, 10:55 AM

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