Counta

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Evening all

Unsure why the following is resulting in an incorrect value.



Cells(1,7).value = application.WorksheetFunction.CountA(Range("B:B")
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Not sure about that one, but it would be easier to just exclude it by definition....

Code:
Cells(1,7).value = application.WorksheetFunction.CountA(Range("B2:B100000") 'or however far down you  have to go

It's no less efficient either way. Right now it's evaluating a few over a million cells...any less is just a nanosecond more efficient :)

And, it's here-nor-there now, but I think I had my threads mixed up while ago. Calculation manual/auto wouldn't have anything to do with that line of code working or not.
 
Last edited:
Upvote 0
I'm definitely losing my self. Below is an excerpt of code provided by, (I believe) the great Mr. Rothstein.

This answers my original need.


Code:
Cells(1, 7).Value = Columns("B").SpecialCells(xlConstants).Count - 1
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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