• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Counting number of rows with number greater than 1

I have a column in my spreadsheet named "Revision".  A sampling of this column data looks like this:

1
1
2
15
1
1
4
1

I need a total count of the rows where the number in it is greater than 1. Not a sum of the numbers but just a count of rows where the number is greater. So for the above sample my count would be: 3

Can anyone help with a function for this?

Thank you.
0
greddin
Asked:
greddin
  • 2
  • 2
  • 2
2 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
0
 
greddinAuthor Commented:
No, I just want to count the rows which are greater than 1.
0
 
Martin LissRetired ProgrammerCommented:
Assuming the data starts in A1 and there are 100 rows

Dim lngIndex As Long
Dim lngCount As Long

For lngIndex = 1 To 100
    If Range("A" & lngIndex).Value > 1 Then
        lngCount = lngCount + 1
    End If
Next
MsgBox lngCount
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Martin LissRetired ProgrammerCommented:
Or better (no need to know how many rows).


Dim lngIndex As Long
Dim lngCount As Long
Dim r As Range

Set r = Range("A1").End(xlDown).Offset(0, 0)

For lngIndex = 1 To r.Row
    If Range("A" & lngIndex).Value > 1 Then
        lngCount = lngCount + 1
    End If
Next
MsgBox lngCount
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
Adjust your range as needed.
=COUNTIF(A2:A30,">1")
0
 
greddinAuthor Commented:
Thanks for the answers guys. I'm accepting ged325's answer as best because it's very clean and efficient. I want to also award MartinLiss some points as well because his would work as well. Thanks again.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now