+ Reply to Thread
Results 1 to 7 of 7

Macro to shift the cell being referenced in a formula.

  1. #1
    Registered User
    Join Date
    02-19-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    3

    Macro to shift the cell being referenced in a formula.

    Say I have a formula in cell A1 of sheet 1. This formula references cell A1 of sheet 2. Is there a macro that, when run, will make the formula reference B1 of sheet 2, and when run again, C1?

    Thanks in advance

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to shift the cell being referenced in a formula.

    What's the formula? Is it just the one reference e.g.; =Sheet2!A1, or more complicated?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Macro to shift the cell being referenced in a formula.

    If it is the formula @AlphaFrog suggests, try this.

    Though I have to say, this is one of those times I hope someone embarrasses me with like a 2 line solution, because this feels....kinda roundabout.

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to shift the cell being referenced in a formula.

    A three line solution for what it's worth...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-19-2016
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    3

    Re: Macro to shift the cell being referenced in a formula.

    Being a tiny bit more specific, there are two formulas that are affected; 'Sheet1'!C3 ='MULTIPLIERS cost'!$A$1 and 'Sheet1'!D3 ='MULTIPLIERS cost'!D3

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Macro to shift the cell being referenced in a formula.

    Awesome, thanks. I knew it would be something like that, but just couldn't think how to use Offset. Kudos, very nice code. And I'm calling that a 1-line solution.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to shift the cell being referenced in a formula.

    Quote Originally Posted by beresfordproductions View Post
    Being a tiny bit more specific, there are two formulas that are affected; 'Sheet1'!C3 ='MULTIPLIERS cost'!$A$1 and 'Sheet1'!D3 ='MULTIPLIERS cost'!D3
    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)

Similar Threads

  1. [SOLVED] Formula to return Blank cell if referenced cell has no entries, if not use formula
    By stpeter in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2016, 01:41 PM
  2. [SOLVED] How to get referenced cell to be recognized by macro
    By kspeese in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-20-2013, 07:25 PM
  3. Replies: 14
    Last Post: 09-04-2013, 12:01 PM
  4. Replies: 5
    Last Post: 05-07-2013, 08:34 AM
  5. [solved] Macro to apply formatting to each referenced cell of a formula
    By raystafarian in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2012, 02:12 PM
  6. Opening a Folder from Referenced Cell (Macro)
    By narr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2011, 10:34 PM
  7. Go to cell referenced in a formula
    By Dennis in forum Excel General
    Replies: 6
    Last Post: 05-30-2006, 04:35 PM

Tags for this Thread

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