Counta with an undefined range

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I need to count the number of nonblanks in column O for numerious sheets/tabs. My problem is: the number of rows could change in each one of the tabs so I dont know what the range will be.

I am looking to put code into each sheet that will calculate on deactivate. I need the formula to count the number of nonblanks in column O and put that anser in Cell T3.

Is this possible?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I need to count the number of nonblanks in column O for numerious sheets/tabs. My problem is: the number of rows could change in each one of the tabs so I dont know what the range will be.

I am looking to put code into each sheet that will calculate on deactivate. I need the formula to count the number of nonblanks in column O and put that anser in Cell T3.

Is this possible?
COUNTIF(O:O,"?*")

counts all text values of length > 0.

If column O also house numeric values...

COUNT(O:O)+COUNTIF(O:O,"?*")
 
Upvote 0
Try this in the Worksheet Object...

Code:
Private Sub Workbook_Deactivate()
Dim i As Integer

For i = 1 To Sheets.Count
    With Sheets(i)
        .Range("T3") = Application.CountA(.Range("O:O"))
    End With
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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