Solved

Counting number of rows with number greater than 1

Posted on 2012-03-22
6
320 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 47

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
Industry Leaders: 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!

 
LVL 47

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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