+ Reply to Thread
Results 1 to 6 of 6

Use Variable as Row Number?

  1. #1
    Registered User
    Join Date
    05-25-2018
    Location
    Logan, Utah
    MS-Off Ver
    Excel 2010
    Posts
    9

    Angry Use Variable as Row Number?

    I need my VBA script to use a variable pulled from the row number of the shape I click on to reference individual cells in that same row

    Please Login or Register  to view this content.

    Gives me the row number of the clicked shape, but how do I incorporate that to select a cell?

    Please Login or Register  to view this content.
    does not use the rn variable as the row number

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Use Variable as Row Number?

    Try this one
    Please Login or Register  to view this content.
    Also, it's safer to Dim rn as Long instead of Integer because Long can handle larger numbers.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    05-25-2018
    Location
    Logan, Utah
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Use Variable as Row Number?

    Hey thanks bakerman2 that was a huge help! Now how do I set the value of cell A1 equal to that of the newly selected cell?

    HTML Code: 
    This did not work at all.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Use Variable as Row Number?

    It should be
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-25-2018
    Location
    Logan, Utah
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Use Variable as Row Number?

    I guess typos tend to happen when programming late at night
    Thanks bakerman2!

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Use Variable as Row Number?

    Late at night ??? It's early in the morning here.

    Glad to help and thanks for rep+.

+ 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] Copy multiple columns x number of times based on variable number?
    By nobodyukno in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-19-2017, 04:13 PM
  2. Macro to cut and paste a variable number of rows to a variable location?
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2015, 07:57 AM
  3. Macro to insert a variable number of rows into a variable location
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2015, 05:31 AM
  4. Replies: 3
    Last Post: 02-17-2015, 11:53 PM
  5. [SOLVED] Calculate average of variable number of cells variable number of times
    By WeirnetherlandsBart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2014, 10:11 AM
  6. Replies: 2
    Last Post: 07-24-2012, 11:47 AM
  7. Replies: 6
    Last Post: 04-14-2012, 04:07 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