COUNTA msgbox

  • Thread starter Thread starter Daminc
  • Start date Start date
D

Daminc

I'm not sure if this is possible but I have been trying to create
macro that would do a COUNTA function on a selected range and displa
the result in a message box

i.e.

Dim Rangea As Range
Dim Resulta As Variant

Rangea = selelected.Range
Resulta = Application.WorksheetFunctions.counta.Rangea
MsgBox Resulta

It doesn't come close to working so can anyone suggest a way o
accomplishing this?

Cheers :
 
try this

worksheetfunction.CountA(columns("B:B"))

fill some entries in columnB
and type this in immediate window
?worksheetfunction.CountA(columns("B:B"))
what do you get
 
Hi Daminc,
Dim Rangea As Range
Dim Resulta As Variant

Rangea = selelected.Range
Resulta = Application.WorksheetFunctions.counta.Rangea
MsgBox Resulta

Close:

Dim Rangea As Range
Dim Resulta As Variant

Set Rangea = selelected.Range
Resulta = Application.WorksheetFunctions.counta(Rangea)
MsgBox Resulta

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
 
Dim result As Integer
result = WorksheetFunction.Counta(Selection)
MsgBox result


--
Gordon Rainsford

London UK


Daminc said:
I'm not sure if this is possible but I have been trying to create amacro
that would do a COUNTA function on a selected range and displaythe
result in a message box
 
Hi Daminc,

You have several code suggestions. However, this information is available
directly in the report on the right-hand side of the status bar,
 
Thanks for your replies.

There are several suggestions that work great here for what I wante
and a lot more food for thought in the bargain :)

I'm not sure where this info is though:
-"However, this information is available directly in the report on th
right-hand side of the status bar,"
 
Hi Daminc,
I'm not sure where this info is though:
-"However, this information is available directly in the report on the
right-hand side of the status bar,"-

If you select some cells, the staus bar can show a number of statistics
(on the right hand side): SUM, COUNT, AVERAGE, MIN, MAX. Rightclick the
status bar to activate this or change the function used.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
 
Hi Daminc,

Just to add to Jan Karels's response, if you do not see the Status Bar then:

Tools Options | View | Check 'Status Bar'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top