Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adjustment to count cells (in range code)
Try,
myCount = Application.Count(Range("A1:A5")) Which works but I prefer Set myrange = Range("A1:A5") myCount = Application.Count(myrange) Mike "Simon" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adjustment to count cells (in range code)
On Aug 1, 11:27*am, Mike H wrote:
Try, myCount = Application.Count(Range("A1:A5")) Which works but I prefer Set myrange = Range("A1:A5") myCount = Application.Count(myrange) Mike "Simon" wrote: 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- Hide quoted text - - Show quoted text - Aha, so logical :-D Thanks Mike! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Code Adjustment | Excel Discussion (Misc queries) | |||
Automatic range adjustment when copying data | Excel Programming | |||
Count cells in one range based on parameters in another range | Excel Worksheet Functions | |||
Aircraft Scheduling Problem VBA code needs adjustment. | Excel Programming |