+ Reply to Thread
Results 1 to 5 of 5

Maintain Formulas / Cell reference help

  1. #1
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Maintain Formulas / Cell reference help

    Hi,

    I have a marco that will insert a new row and then add formulas to some of the new cells.

    My problem is formating the formula to reference the correct cell.

    My formula is
    =DATE(YEAR(D13])+1,MONTH(D13),DAY(D13))

    The problem being is that I need not to always reference cell D13, but the Cell that is -3 colums from the cell that contains the formula, as the value of this cell is different every time.

    So ideally I would like a way of writing:
    =DATE(YEAR((OFFSET([this cell],0,-3)))+1 etc

    where [this cell] references the cell that the formula is in without any changes to the formula..

    Any ideas?

    Have tried the Indirect and Cell Adress fuinctions alongside the offset function but I cant get anything to work!

    Thanks

    Wil

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Maintain Formulas / Cell reference help

    Use R1C1 notation in your code, ie:

    Please Login or Register  to view this content.
    Anything appearing within [ ] is a relative adjustment based on the current cell, if a number appears after R/C outside of [ ] it is an absolute reference, ie R2C3 is like $C$2.

    That said the formula you're using is open to error if the date happens to be 29th Feb (ie a leap year)

  3. #3
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Re: Maintain Formulas / Cell reference help

    Thats great, thanks

    why do I get a compile error when trying to add this formula to the macro?

    Please Login or Register  to view this content.
    I receive 'Compile Error: Expected )'

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Maintain Formulas / Cell reference help

    Perhaps

    Please Login or Register  to view this content.
    if you need " literally then double them "" ... also FormulaR1C1 is an equal of .Value etc... so used as alternative to .Value rather than as a child of.

  5. #5
    Registered User
    Join Date
    01-13-2009
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2003
    Posts
    52

    Re: Maintain Formulas / Cell reference help

    Yeah, I figured the .Formula acted inpalce of .value that was me having not enough caffine!

    It all works perfectly, I can now apply that process to other issues that I was having!

    Thanks AGAIN,

    Wil

+ 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