Stop new lines changing formula

MJLP

New Member
Joined
Mar 26, 2008
Messages
21
I have this formula in a spreadsheet:

=COUNTIFS($B$7:$B$998, "*"&B$2&"*" etc...

My problem is, when people add new lines to the spreadsheet for new data, the formula automatically changes.

For example, if someone added a new line, and moved row 7 down, I would want the formula to still include this new line, but it automatically updates to:

=COUNTIFS(Incidents!$B$8:$B$999, "*"&B$2&"*"

Is there anyway to stop this from happening?

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

MJLP

New Member
Joined
Mar 26, 2008
Messages
21
Thanks for the reply.

I am having a little trouble as the reference is actually for a different sheet, the formula is:

=COUNTIFS(YTD!$B$7:$B$998,

Should I make it:


=COUNTIFS(INDIRECT("YTD!$B$7"):$B$998, etc</pre>
 

dafan

Well-known Member
Joined
May 6, 2008
Messages
692
No try:
Code:
=COUNTIFS(INDIRECT("YTD!$B$7"):YTD!$B$998, etc
 

MJLP

New Member
Joined
Mar 26, 2008
Messages
21

ADVERTISEMENT

Thanks for that - worked a treat!

What exactly does INDIRECT do?
 

dafan

Well-known Member
Joined
May 6, 2008
Messages
692
From the help file:
Returns the reference specified by a text string

In other words: "$B$7" will be seen as a text string by Excel and will therefore not be altered when you insert a new row above. It will be evaluated later by INDIRECT, which turns it into a range reference, completing $B$7:$B$998.
 

MJLP

New Member
Joined
Mar 26, 2008
Messages
21
Great stuff - thank you very much for taking the time to help me out, it is very much appreciated!

I don't think I would ever have worked this out on my own!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,382
Messages
5,836,931
Members
430,463
Latest member
mikmob

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
Top