Use DATEDIF formula in macros for unfixed cells (Eg, Cells (b, c))

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicolenwn
    New Member
    • Nov 2009
    • 23

    Use DATEDIF formula in macros for unfixed cells (Eg, Cells (b, c))

    I need my macro to calculate the date difference between 2 ranges in 2 different sheets.

    Ive got the codes below using record macro, however my range is not fixed as i'm using unfixed cells like (Cells (b, c)).

    Code:
    ActiveCell.FormulaR1C1 =
            "=DATEDIF(R[5]C,'production breakdown'!R[-5]C[1],""d"")"
    I've tried
    Code:
    Cells(b, c) = DATEDIFF("d",(Cells(b,y)),'Production Breakdown'!B2)
    &
    
    Cells(b, c).FormulaR1C1 = "=DATEDIF(RC[-1],'Production Breakdown'!B2,""d"")"
    But this doesn't work.
Working...