Forum Discussion

hrh_dash's avatar
hrh_dash
Iron Contributor
Jul 26, 2022
Solved

Dynamic subtraction macro showing the formula

I would like to create a dynamic subtraction macro which would display the formula.   Currently it is populating an error msg: "run time error 1004 application or object-defined error"   Below is...
  • OliverScheurich's avatar
    Jul 26, 2022

    hrh_dash 

    Sub subtract()
    
    Dim maxrow As Long
    
    maxrow = Tabelle1.Cells(Rows.Count, 2).End(xlUp).Row
    
    Range(Cells(12, 4), Cells(maxrow, 4)).FormulaR1C1 = "=RC[-2]-RC[-1]"
    
    End Sub

    Maybe with this code. In the attached file you can click the button in cell F5 to run the macro.

Resources