+ Reply to Thread
Results 1 to 6 of 6

Define a Variable that equals the Row Number I have selected when I start the Macro

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    6

    Define a Variable that equals the Row Number I have selected when I start the Macro

    Hello,

    The answer to the subject will solve my problem--if I place my cursor in a cell and then start a macro, can I get it to "grab" the row number I'm in for use later in the macro? I've tried a few things with relative references, trying to equate things, and trying to play with the data type, but I can't get it to work.

    Thank you!

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Define a Variable that equals the Row Number I have selected when I start the Macro

    gle,

    Try ActiveCell.Row or Selection.Row
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-05-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Define a Variable that equals the Row Number I have selected when I start the Macro

    Hi tigeravatar,

    Thanks for the help. Unfortunately, I can't just use the relative references, because I need the row to transfer over multiple other spreadsheets in the same workbook to perform specific operations there. So (I think) I need a variable that actually defines the row number that would be defined by ActiveCell.Row or Selection.Row. Make sense?

    Thanks!

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Define a Variable that equals the Row Number I have selected when I start the Macro

    gle,

    No, that doesn't really make sense. I was suggesting that you assign a variable to the value of ActiveCell.Row or Selection.Row at the beginning of your macro:
    Please Login or Register  to view this content.

    If for some reason that doesn't work for you, then we're going to need more information.

  5. #5
    Registered User
    Join Date
    07-05-2013
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Define a Variable that equals the Row Number I have selected when I start the Macro

    Sorry, had my mind in a bit of a rut, wasn't thinking about that route to solve the problem. Makes sense! Sorry to bother for such a simple question.

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Define a Variable that equals the Row Number I have selected when I start the Macro

    No need to apologize, we've all been there

+ 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. How to define variable from selected row to be used in FOR LOOP
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2012, 01:42 PM
  2. Using CountA to define a number variable
    By paddingtonstation in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2012, 01:15 PM
  3. Macro to start when cell selected
    By JackR in forum Excel General
    Replies: 8
    Last Post: 03-20-2006, 12:10 PM
  4. Define worksheet as variable, then call in macro
    By bugman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2005, 01:20 PM
  5. Determine currently selected cells at start of macro
    By Piers 2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2005, 10:06 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