Results 1 to 4 of 4

COUNTA Function in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    11-16-2006
    Posts
    80

    COUNTA Function in VBA

    Hi All,

    I have a column with dates (UK format). What I want to do is select a range in that columns and count the number there are, i.e:

    Column A

    01/03/2007
    02/03/2007
    03/03/2007
    04/03/2007
    05/03/2007

    Say I select rows 2 to 3 in column A, when I run the macro I want a msgBox to return, "You selected 3". This is what I have:

    Sub test()
        Dim selAddress As String
        Dim numSelected As Integer
    
        selAddress = Selection.Address
        numSelected = WorksheetFunction.CountA(selAddress)
       
        msgBox("You selected " & numSelected)
    
    End Sub
    My problem is, that the function keeps returning 1, no matter how many I select. I have attached an example for you to look at

    Thanks,
    mccreaso
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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