I am using a formula which will calculate a value using index and match and the output is subtracting from another cell B2 value.I need to keep B2
as common subtracting component across all cell
I am using below formula in cell C2
=IFERROR(B2-(INDEX(raw!$A:$D,MATCH(1,(raw!$A:$A=data!$A2)*(raw!$C:$C=data!C$1),0),4)),"")
But If I drag this formula to next cell, D2
The formula is getting change to
=IFERROR(C2-(INDEX(raw!$A:$D,MATCH(1,(raw!$A:$A=data!$A2)*(raw!$C:$C=data!D$1),0),4)),"")
C2
is replacing B2
I want to keep B2
as constant
Below is the VBA macro created :
Sub Macro7()
'
' Macro7 Macro
'
Selection.FormulaArray = _
"=IFERROR(RC[-1]-(INDEX(raw!C1:C4,MATCH(1,(raw!C1=data!RC1)*(raw!C3=data!R1C),0),4)),"""")"
Selection.AutoFill Destination:=ActiveCell.Range("A1:D1"), Type:= _
xlFillDefault
ActiveCell.Range("A1:D1").Select
End Sub
If I manually edit the formula in each cell, it is working fine (changing, C2,D2,E3,F2
etc to B2
). But I am using this formula in 100s of cells and manually editing all is not practically possible. Is there anyway I can change the VBA to keep B2 as constant across the range of cell to run this formula ?
=IFERROR($B$2-...
– user2140173