+ Reply to Thread
Results 1 to 6 of 6

Offset with a variable

  1. #1
    Registered User
    Join Date
    08-06-2018
    Location
    France
    MS-Off Ver
    10
    Posts
    3

    Offset with a variable

    Hi guys,
    my problem seems very simple but still can't find a solution.
    If i have in A1 variable number how can i integrate it into vba offset formula.
    Let's say A1=5 and i want that vba goes from B1 by 5 cells down (5 cells comes from A1)...

    please SOS

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Offset with a variable

    Please Login or Register  to view this content.
    This will refer to Range("B6"), given that A1=5
    Note that you need to take care to not fall outside e.g. negative Row numbers (e.g. negative number in A1) or more than Rows.Count numbers
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    08-06-2018
    Location
    France
    MS-Off Ver
    10
    Posts
    3

    Re: Offset with a variable

    Oh god!!! Fantastic!!! thank you so so much! it IS so simple but it's not written anywhere! thank you so much again!

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Offset with a variable

    Quote Originally Posted by Tati123 View Post
    it IS so simple but it's not written anywhere!
    well
    https://msdn.microsoft.com/en-us/VBA...property-excel

  5. #5
    Registered User
    Join Date
    08-06-2018
    Location
    France
    MS-Off Ver
    10
    Posts
    3

    Re: Offset with a variable

    Well, that doesn't seem so easy as your answer

    Buran, if i don't stop just at selection a cell but by the end of macro i should have 4 cells selected from the one which was offset?

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Offset with a variable

    Note that in VBA you almost NEVER need to select anything (there are only few notable exceptions).
    It's not completely clear what you [want to] do, but one way to reference 4 cells down starting from B6
    Please Login or Register  to view this content.
    As I said it's unclear what you want to do, so this is just a suggestion

+ 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. Select offset variable offset cells
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2014, 06:12 AM
  2. Using Offset in VBA with a Variable
    By Jietoh in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 11-06-2013, 01:24 PM
  3. Using a variable in .offset
    By GaidenFocus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2012, 04:20 PM
  4. Using variable in OFFSET function
    By kmoore in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2011, 12:13 PM
  5. Activecell offset with Variable
    By sgreni in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2011, 05:42 PM
  6. Offset with variable?
    By John in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2006, 03:35 PM
  7. [SOLVED] Offset with variable
    By James in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2005, 04:05 PM

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