+ Reply to Thread
Results 1 to 5 of 5

VBA offset inside a formula

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    VBA offset inside a formula

    Hi all,

    I an trying to write code where when using a macro a formula will offset and look for the values on the left.

    For example I have cell G7 where I have the following formula: ='[Charts_Dashboard_Masterfile.xlsx]C-PIB'!R4
    And I would like a code that everytime I use it changes my formula to ='[Charts_Dashboard_Masterfile.xlsx]C-PIB'!S4 and then to ='[Charts_Dashboard_Masterfile.xlsx]C-PIB'!T4 and so on.

    I have tried it using offset but it does not seem to work. Does anyone have an idea of how to do it?

    Please Login or Register  to view this content.
    Thank you,

    Daniel

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA offset inside a formula

    I dont quite get what you want to do and how the code you post would fit into it, but your formular1c1 line doesn't work because you are use the offset function inside quote marks. you would need something more along the lines of:
    Please Login or Register  to view this content.
    to untilize the offset function.

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: VBA offset inside a formula

    Your code does not work because what I want to offset is the value "R4C".
    Like it does not necessarily means that it has to be an offset. What I basically want is to copy and paste the values from that R4C, the trick is that each time I run the macro I want it to look for the cell on the next column

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA offset inside a formula

    Like I said, I didn't understand what you want to do or how the code you posted would achieve it, that was just an example of how to combine a function such as offset in an r1c1 reference.

    To do what you want, you probably need something more like:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA offset inside a formula

    Maybe using a Helper Sheet with numbers starting at 19 for Range A1 and increasing going down.
    Please Login or Register  to view this content.
    Your final code may look something like this:

    Please Login or Register  to view this content.

+ 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