+ Reply to Thread
Results 1 to 5 of 5

Using variable in OFFSET function

  1. #1
    Registered User
    Join Date
    07-18-2011
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Using variable in OFFSET function

    Is there a way I can use a variable as a parameter in the offset function in VBA. I tried teh following code where cnt3 represents the current column. Its used in a loop.

    Please Login or Register  to view this content.
    On Sheet2, cell C27 I need to read the values from Sheet1, cell B16. I need to repeat that skipping a column on Sheet2, but not on Sheet1. The loop I created takes me to the correct cell on Sheet two, I just need to figure out how to alter the offset function for each cell. The number of columns can vary each time it runs.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by kmoore; 07-22-2011 at 12:13 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Using variable in OFFSET function

    I can't open your file, but try this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-18-2011
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Using variable in OFFSET function

    Thanks Stephen. That did the trick, excpet I need the reference cell to stay constant. How can I modify your code so the reference call stays constant. I tried the following and it does not work.

    Please Login or Register  to view this content.
    Thank you again!!

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Using variable in OFFSET function

    You can't mix the R1C1 and the other notation, try this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-18-2011
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Using variable in OFFSET function

    Thank you so much

+ 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