Status Bar : Display both Sum and Count

K

Keerthy

Hello Experts!

I would like to show both Sum and Count of the selected cells on the
status bar. How can I do that?

-Keerthy
 
N

Norman Jones

Hi Keerthy,

The following represents an adaptation of code posted by Ron de Bruin and
perhaps it nay be of use to you:

'=============================>>
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
On Error GoTo ErrHandler:
With Application
.StatusBar = "Sum: " & Application.Sum(Target) & " | " _
& "Count(Nums): " & .WorksheetFunction.Count(Target) _
& " | Count(items): " & Application.CountA(Target) _
& " | Average: " & Application.Average(Target)
End With
Exit Sub
ErrHandler:
Application.StatusBar = False
End Sub
'<<=============================

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not a standard module or a sheet module):

************************************************************
Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
************************************************************
 
S

S K

Hello Norman Jones,

Thanks! that helps. I was wondering if I have to cut and paste this in
every workbook!? Can't this be available on the excel immeterial of
which work book (file) I'm working on?

-Keerthy
 
N

Norman Jones

Hi Keerthy,

Open a new workbook and paste the code into the ThisWorkbook module. Then,
save the workbook, with a suitable name, selecting 'Template' in 'Save as
Type' dropdown.

Thereafter, any workbook opened from the template, will have the same
functionality.

If you truly want this code in *all* new workbooks, then open the default
workbook template (Book.xlt) in the XLSTART folder, paste the code and save.
 

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

Top