dynamic counta with VBA

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I have a column where the number of rows populated will change, but I want to use the =counta formula to calculate the number of populate rows.

In the example below, the formula in cell A1 is =COUNTA(A3:A5), as it counts everything below cell A2, which has the word 'List' in it.

Is there a way to use VBA to count the number of rows below cell A2 regardless of how many rows are populated?

Cells A3, A4 and A5 have the values 1, 2, and 3, respectively. And the =counta formula in cell A1 correctly returns 3 rows.

But what if cell A6 had a value it it? Is it possible to update the counta so that it takes additional rows? Or reduced rows if on cells A3 and A4 had values?

Please let me know if you want me to clarify the question.


3​
List
1​
2​
3​
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You can just use COUNTA(A3:A1048576)
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

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