I have an Excel 2010 formula in an Excel cell like this (the formula lies in column T):
=SUMIF($B$14:$B$44335;$T8;$E$14:$E$44335)
This formula does this: It finds the cells in the Range("B14:B44335") which have the value as Range("T8") (For example, between Range("B192:B370")), then it sums up the values in the column E (For example, sums up between Range("E192:E370")).
The formula works fine, but a background VBA-code couses problem. This VBA code sometimes extends or shorten Range("B14:E44335"). The VBA-code uses insert shift:=xlDown or delete shift:=xlUp for extending or shortening.
Insert shifting (inserting 178 rows) in VBA causes that the formula changes like this:
=SUMIF($B$192:$B$43623;$T8;$E$192:$E$43623)
So the formula also shifts from B14 to B192.
This is strange, because the formula is in the column T, and the VBA-code has nothing to do with the column T.
I tried to give a name to the range like, when I write Countries, then Excel selects the Range("B14:E44335"), so
=SUMIF(Countries;$T8;$E$14:$E$44335)
But i got the same problem again. After Insert Shift, Countries shows Range(B192:B43623")
In anyway, how can I keep the range in my formula permanent, no matter what happens in other cells?
$B$14:$B$44335are 14 and 44335 "fixed" and never change? or are they actually based on some logic ? - DittoB14in your example would not be affected, only the bottom rows. Since you say the code does not even affect column T, can you change the code to only insert / delete the necessary rows / columns instead of theEntireRoworEntireColumn? In this way, your existing formula references would not be affected. - Scott HoltzmanB14when VBA does insert shift to the beginning of the range - user3714330