Results 1 to 4 of 4

Thread: Used rows count

  1. #1
    Member
    Join Date
    2009-04
    Posts
    2

    Default Used rows count

    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

  2. #2
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    4,776

    Default Re: Used rows count

    Have you tried using the LOOKIUP function?
    C:> ED WORKING....

  3. #3
    Active Member ed.w.cler's Avatar
    Join Date
    2008-02
    Location
    Central IL
    Posts
    53

    Default Re: Used rows count

    I assume you are using MS Excel.
    If you change your syntax a little, this format works for me
    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
    Let me know if this helps.
    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

  4. #4
    Active Member ed.w.cler's Avatar
    Join Date
    2008-02
    Location
    Central IL
    Posts
    53

    Default Re: Used rows count

    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

Similar Threads

  1. 2010: Delete or Add Rows
    By eyde in forum AutoCAD Tables
    Replies: 0
    Last Post: 2012-03-29, 10:04 PM
  2. Can Rows in Sub-Panels pan?
    By Liamnacuac in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2011-10-12, 12:14 PM
  3. DB to create staggered rows
    By nextvkin in forum Dynamic Blocks - Technical
    Replies: 3
    Last Post: 2009-05-06, 04:23 AM
  4. Numbered rows in schedules
    By radoss in forum ACA Wish List
    Replies: 1
    Last Post: 2009-02-02, 06:21 AM
  5. Add rows to drawing list
    By mmolina in forum Revit Architecture - General
    Replies: 3
    Last Post: 2005-11-01, 05:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •