Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting Cells containing especific Values

Tags:

excel

vba

Hi im new using excel and i would like to count the cell that containg the values betweeen 500 and 750. this is the code that i wrote but i did something wrong that is not giving me the right answer. Can some one please help?

Sub Count()
    Dim i As Integer
    Dim j As Integer

    Range("C3").Select

    For i = 1 To 279
        For j = 1 To 19
            If i > 500 Then
            ElseIf i <= 750 Then
                i = i + 1
            End If
        Next j
    Next i

    Sheets("Sheet1").Select
    Range("B13").Select
    ActiveCell.Value = i
End Sub
like image 872
user2385030 Avatar asked Nov 30 '25 15:11

user2385030


1 Answers

Why use VBA for that?

Use COUNTIFS() function. Just enter it in cell B13 and adjust the range from A:A to whatever range you need to check in the formula.

=COUNTIFS(A:A, ">=500", A:A, "<=750")
like image 190
peterm Avatar answered Dec 02 '25 05:12

peterm