+ Reply to Thread
Results 1 to 6 of 6

Assigning a Row Number to a variable in a macro

  1. #1
    Registered User
    Join Date
    11-05-2007
    Posts
    82

    Assigning a Row Number to a variable in a macro

    A simple one I hope:

    I have a macro that is formatting a load of data, within the macro - i am trying to assign the row number of the current cell to a variable, for use at the end of each loop.

    Any help would be ghreat - thanks.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Assigning a Row Number to a variable in a macro

    Neil07979, can you post your code ?
    (be sure to use CODE tags - use the # button)

    You rarely need to use ActiveCell in code... and you may find you can format ranges in batches to speed up your code execution...

  3. #3
    Registered User
    Join Date
    11-05-2007
    Posts
    82

    Re: Assigning a Row Number to a variable in a macro

    Not much to it at the moment - its the first thing I need to do:

    Please Login or Register  to view this content.
    Thanks

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Assigning a Row Number to a variable in a macro

    OK, in which case let me re-phrase it: what are you trying to achieve ?

  5. #5
    Registered User
    Join Date
    11-05-2007
    Posts
    82

    Re: Assigning a Row Number to a variable in a macro

    All I need to do is be able to assign the row number of the current cell to a variable.

    So I have declared the variable as RowNumber, selected cell A8 - and I want 8 to be stored.

    This will then be used further through the loop, to reference back and paste other information to a certain cell within Row 8.

    Thanks

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Assigning a Row Number to a variable in a macro

    OK, I don't have the time to spend trying to elucidate further on why you're unlikely to need this and you seem unwilling to outline what is you're trying to do with the entire routine so to answer your question

    Please Login or Register  to view this content.
    or if you're selecting a specific cell (eg A8) just set the value to the row which you know already given you're using a predefined selection

    Please Login or Register  to view this content.
    Note: use Long type for Row Variables - Integer is susceptible to error ... moreover Integers are converted to Long under the hood in 32-bit VBA so there really is no value in using the Integer type anyway.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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