View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Simon[_2_] Simon[_2_] is offline
external usenet poster
 
Posts: 89
Default Adjustment to count cells (in range code)

Sub CountNonBlankCells2() 'Returns a count of non-blank
cells in a selection
Dim myCount As Integer 'using the Count ws function
(only counts numbers, no text)

myCount = Application.Count(Selection)

MsgBox "The number of non-blank cell(s) containing numbers is : " &
myCount, vbInformation, "Count Cells"
End Sub

I'd like to have the option of specifying a range but

myCount = Application.Count("A1:A5")

doesn't work, why? What should I do

Thanks