Solved

# Counting number of rows with number greater than 1

Posted on 2012-03-22
313 Views
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
Question by:greddin
• 2
• 2
• 2

LVL 39

Expert Comment

ID: 37754731
0

Author Comment

ID: 37754738
No, I just want to count the rows which are greater than 1.
0

LVL 45

Expert Comment

ID: 37754757
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

LVL 45

Assisted Solution

Martin Liss earned 100 total points
ID: 37754781
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

LVL 39

Accepted Solution

Kyle Abrahams earned 400 total points
ID: 37754804
=COUNTIF(A2:A30,">1")
0

Author Closing Comment

ID: 37755256
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

### Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.