+ Reply to Thread
Results 1 to 7 of 7

Counting Occupied cells

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Counting Occupied cells

    Hey everyone, im wondering how i can count how many cells in a certain collumn are occupied.
    for example, in Collumn A I have a list of phone numbers that begin with 519, and in collumn B i have a list of phone numbers that begin with 416. I need code that can count how many cells in collumn A are occupied (to see how many 519 phone numbers there are) and have that number displayed in M1.

    Thanks :D

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: Counting Occupied cells

    Try this:

    =COUNTA(A:A)

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    10-15-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Counting Occupied cells

    Could you provide a dummy excel?

    Babu

  4. #4
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Counting Occupied cells

    okay im not quite sure how to implement this (I am very new to VB) would i put:

    Range(G330).Value = Count("A:A")

    (to display the count in cell G330)

  5. #5
    Registered User
    Join Date
    10-16-2012
    Location
    Guelph, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Counting Occupied cells

    This is my code that sorts my imported data and prints all the numbers with a "519" area code to collumn A on another sheet:

    Sub MoveNumbers905()
    Dim K As Long
    K = 1
    Dim s1 As Worksheet, s2 As Worksheet
    Set s3 = Sheets("Sheet3")
    Set s2 = Sheets("Sheet2")
    Dim rG As Range
    Set rG = Intersect(s2.Range("G:G"), s2.UsedRange)
    Dim r As Range
    Dim st As String
    st = "(905)"
    For Each r In rG
        If InStr(r.Value, st) > 0 Then
            s3.Cells(K, 11).Value = r.Value
            K = K + 1
        End If
    Next
    End Sub
    So after using this code, I have collumn A filled up with all the 519 numbers from my imported data. Now i want to count the number of cells that are occupied and display that number in cell G330 by pushing a button
    Last edited by Cutter; 10-17-2012 at 08:45 AM. Reason: Added code tags

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: Counting Occupied cells

    You posted in the General Forum, and you didn't say anything about VBA or a macro in post #1, so I gave you a formula solution - put the formula in M1.

    Hope this helps.

    Pete

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Counting Occupied cells

    @ ohaganli

    Welcome to the forum.

    Please notice that [CODE] tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1