Counta changes cell references when delete or add row

4653

New Member
Joined
Apr 20, 2012
Messages
27
Office Version
  1. 365
Platform
  1. Windows
I am using =COUNTA($B$2:$B$4000) to determine the number of cells that are not blank in cell range B2 through B4000. Row one is a frozen row so it always remains visible if that matters and the COUNTA is in cell B1. Every time I insert a row anywhere in the range B2 to B4000 it changes B2 to B3 in the COUNTA formula and if I delete a row it will change back from B3 to B2. I want the range within the formula to remain constant regardless of whether I insert rows or delete them. Any help would be much appreciated.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I am using =COUNTA($B$2:$B$4000) to determine the number of cells that are not blank in cell range B2 through B4000. Row one is a frozen row so it always remains visible if that matters and the COUNTA is in cell B1. Every time I insert a row anywhere in the range B2 to B4000 it changes B2 to B3 in the COUNTA formula and if I delete a row it will change back from B3 to B2. I want the range within the formula to remain constant regardless of whether I insert rows or delete them. Any help would be much appreciated.

Try,

=COUNTA(INDIRECT("$B$2:$B$4000"))
 
Upvote 0
Try,

=COUNTA(INDIRECT("$B$2:$B$4000"))
Since the range references within the INDIRECT function are quoted this evaluates to a TEXT string and as such, a text string will never change if the formula is copied. So, we can eliminate the dollar signs $:

=COUNTA(INDIRECT("B2:B4000"))

The range will automatically be evaluated as an absolute range.

Another way to do it:

=COUNTA(INDEX(B:B,2):INDEX(B:B,4000))
 
Upvote 0

Forum statistics

Threads
1,216,471
Messages
6,130,823
Members
449,595
Latest member
jhester2010

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