Count number of rows which contain text

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

I need to have a VBA code that looks at rows in a range and gives back the number of rows which contain text in any of their cells (only text not numbers).

For example for range(B3:H10) if there is text in cells C3, F3, D9, G10, H10 then the number I should get is 3 because we have text in row B3:H3, in row B9:H9 and in row B10:H10.

The result can be found in cell A2.

How would I do that?

Thanks,
Nic :unsure:
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Formula version
Excel Formula:
=sumproduct(--ISTEXT(B3:H10))
 
Upvote 0
Hi,

This formula returns number of CELLS in range(B3:H10) which have text in this case 5.
I need number of ROWS which contain text in this specific case 3.

Thanks,
Nic
 
Upvote 0
Maybe this:
VBA Code:
Sub try_1()
Dim c As Range
Dim q As Long
With Range("B3:H10")
    q = .Columns.Count
    For Each c In .Columns(1).Cells
        If WorksheetFunction.CountA(c.Resize(1, q)) > 0 Then n = n + 1
    Next
End With
Range("A2") = n
End Sub
 
Upvote 0
Solution
Or with a formula
Fluff.xlsm
ABCDEFGH
1
23
3aa
4
51
6
71
81
9a1
10aa
Data
Cell Formulas
RangeFormula
A2A2=SUM(BYROW(B3:H10,LAMBDA(br,SIGN(SUM(--ISTEXT(br))))))
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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