I am trying to create excel macro that changes a value in a formula with clipboard value.
I want to have relative addressing for some part of the formula and absolute addressing for remaining part of formula. Absolute address value I want to paste from clipboard.
For example in the below code,
ActiveCell.FormulaR1C1 = "=RC[-11]*(RC[-2]+R[-34]C[-2])"
In place of R[-34]C[-2]
I want to give R[-75]C[-2]
and I have this 75
in clipboard.
So, whenever I execute the macro 2nd part of formula should take an absolute address from clipboard.
My current code is as follows:
Sub Macro1()
ActiveCell.FormulaR1C1 = "=RC[-11]*(RC[-2]+R[-34]C[-2])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-16]=1,RC[-18]-R[-34]C[-18],1)"
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
Appreciate any help in this regard.