PDA

View Full Version : emulate the satuesbar



lior03
10-29-2007, 03:53 AM
hello
i want to use excel builtin functions to let the user get a quick summaty of a selection.
how many data cells ,there sum average and so on:

On Error GoTo err
If Application.WorksheetFunction.CountA(selection) = 0 Then
MsgBox " selection - " & selection.Address & " - is empty", vbExclamation, "selection is empty"
Else
MsgBox "selection - " & selection.Address & " - is not empty:" & Chr(13) _
& Chr(10) & "Numeric count is - : " & Application.WorksheetFunction.count(selection) & Chr(13) _
& Chr(10) & "empty count is - : " & Application.WorksheetFunction.CountBlank(selection) & Chr(13) _
& Chr(10) & "data count is - : " & Application.WorksheetFunction.CountA(selection) & Chr(13) _
& Chr(10) & "Sum is - : " & Format(Application.WorksheetFunction.Sum(selection), "##,##.00") & Chr(13) _
& Chr(10) & "Average is - : " & Format(Application.WorksheetFunction.Average(selection), "##,##.00") & Chr(13) _
& Chr(10) & "Median is - : " & Format(Application.WorksheetFunction.Median(selection), "##,##.00") & Chr(13) _
& Chr(10) & "Max - : " & Format(Application.WorksheetFunction.max(selection), "##,##.00") & Chr(13) _
& Chr(10) & "Min - : " & Format(Application.WorksheetFunction.Min(selection), "##,##.00") _
, vbInformation, "selection quick numeric info:"
Exit Sub
err:
MsgBox "selection do not have numerical values", vbCritical, "error!!"
End If


then i wanted to count how many cells has text (no numeric and no blank)

Function countext(r As Range)
Application.Volatile
Dim i As Integer
Dim cell As Range
i = 0
For Each cell In r
If Not IsNumeric(cell) Then
i = i + 1
i = countext
End If
Next
End Function

how can i cout the numberof cells in as selection which are not empty or has numeric value?
thanks

Bob Phillips
10-29-2007, 04:41 AM
MsgBox Application.COUNTIF(Selection,"<>"")




MsgBox Activesheet.Evaluate("SUMPRODUCT(--ISNUMBER(" & Selection.Address &"))")