Solved

Counting number of rows with number greater than 1

Posted on 2012-03-22
6
318 Views
Last Modified: 2012-03-22
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
Comment
Question by:greddin
  • 2
  • 2
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37754731
0
 

Author Comment

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

Expert Comment

by:Martin Liss
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 46

Assisted Solution

by:Martin Liss
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 40

Accepted Solution

by:
Kyle Abrahams earned 400 total points
ID: 37754804
Adjust your range as needed.
=COUNTIF(A2:A30,">1")
0
 

Author Closing Comment

by:greddin
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question