+ Reply to Thread
Results 1 to 6 of 6

How to assign offset for a variable

  1. #1
    Registered User
    Join Date
    12-25-2012
    Location
    Bangalroe
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question How to assign offset for a variable

    Hi

    I need to count the last row in a col and take that as reference & use offset function, i have done programming like this.
    Sub calculation
    Please Login or Register  to view this content.
    Here it stops at set rng1 command as E count is a number and not cell number. now i dont know how to take the last row & use offset.

    Moderators note: code tags added for you - this time
    Last edited by shailaja_prasad; 12-27-2012 at 05:39 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to assign offset for a variable

    Hi, shailaja_prasad,

    welcome to ExcelForums.

    Is it by default that both rng1 and rng2 show the same range?

    Please Login or Register  to view this content.
    The following line of code is showing two faults:
    Please Login or Register  to view this content.
    A Range-Object should always contain the column identifier and a row number if you do not refer to a column.
    Please Login or Register  to view this content.
    ECount hasnīt been dimmed nor filled in your code.

    Please use Code-Tags for displaying your code as requested by the Forum Rules.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: How to assign offset for a variable

    Basic example of how to use LastRow with offset
    Please Login or Register  to view this content.
    or seeing as you are trying to use WorksheetFunction
    Please Login or Register  to view this content.
    Edit: Please read the previous post by Holger (posted as I was typing)
    Last edited by WasWodge; 12-25-2012 at 03:39 AM.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  4. #4
    Registered User
    Join Date
    12-25-2012
    Location
    Bangalroe
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How to assign offset for a variable

    No rng1 & rng2 are 2 different ranges.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: How to assign offset for a variable

    shailaja, welcome to the forum

    however, Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to assign offset for a variable

    Hi, shailaja_prasad,

    maybe you should ask a Moderator to rework the code in the opening post - thereīs only one opening [ code ] Tag and one closing [ /code ] and not a Code Tag for each and every line of code.

    Please Login or Register  to view this content.
    looks very much the same to me.

    If the range has an even number of entries you can simplify the code to get the last filled line with data. Otherwise this may give a hint on how to solve the issue (only for Column E):
    Please Login or Register  to view this content.
    I think you defined way too much variables that may be omitted and the code may be simplified and straightened.

    Ciao,
    Holger

+ 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