VBA to Keep Same Formula Row/column Reference after new row is inserted

AndyJR

Board Regular
Joined
Jun 20, 2015
Messages
90
HI all,

I'm using many different formulas with row/columns reference (located in F4: Q14)
the problem that i'm getting is that on daily basis i have to insert a new row (ROW 37) - Data start on row 37 -
after the insertion the Formulas stay but it change the cell/columns reference.

Example:
among many different formulas in cell E4 i'm using these Formula with cell reference
Rich (BB code):
= COUNTIF($E37:$I43,$E4)


then after i Insert on Row 37 and input new information

the formulas row/columns reference (located in F4: Q14) change to
Rich (BB code):
= COUNTIF($E38:$I44,$E4)

And what i need to keep the
formula that references the row/column position in the
spreadsheet regardless of if Row are inserted or deleted so that after
inserting a new row.

Note : it happen the same thing using either absolute/Relative reference.


Any help please?


AndyJr

 
Last edited:
I don't think that formula is what you're after, in which case try:

Code:
Sub AddIndirect()
Dim c As Range
For Each c In Range("f4:tv14")
c.formula = Replace(Replace(Replace(Replace(c.Formula, "COUNTIF(", "COUNTIF(INDIRECT("""), ",", "),INDIRECT("""), "),", """),") & ")", "))", """))")
Next c
End Sub
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,588
Messages
6,125,691
Members
449,250
Latest member
azur3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top