I am trying to count the number of cells in a sepecific column that contain the letter "x".
I
I tried:
Sub do_count()
For i = 2 to 5
MsgBox Sheet(1).Cells(i, 2).UsedRange.Rows.Count
End Sub
I am trying to count the number of cells in a sepecific column that contain the letter "x".
I
I tried:
Sub do_count()
For i = 2 to 5
MsgBox Sheet(1).Cells(i, 2).UsedRange.Rows.Count
End Sub
Have you tried using the LOOKIUP function?
C:> ED WORKING.... ▒
I assume you are using MS Excel.
If you change your syntax a little, this format works for me
Let me know if this helps.Code:Sub ThisUsedRange() Dim Rows As Integer Dim Columns As Integer Columns = ActiveSheet.UsedRange.Columns.Count Rows = ActiveSheet.UsedRange.Rows.Count MsgBox "There are " & Columns & " used columns and " & Rows & " used rows." Dim xCount As Integer Dim Col As Integer 'This is the column in your sheet where you are looking for the "X" Col = 2 For i = 1 To Rows If Cells(i, Col) = "x" Then xCount = xCount + 1 End If Next MsgBox "There were " & xCount & " x's found" End Sub
Last edited by ed.w.cler; 2009-04-09 at 12:42 PM.
Ed
Dell Precision T3400 - Q6600 @ 2.4GHz 8GB Ram - Nvidia Quadro FX 3700
a much easier way to count and sum up data is by using a pivot table. If you are not aware of them, then i think the MS help would be good for you.
Ed
Dell Precision T3400 - Q6600 @ 2.4GHz 8GB Ram - Nvidia Quadro FX 3700