Average Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am not very familiar with the syntax to write macros. If someone could
give me a step by step on how to do this I would really appreciate it.

I want to be able to highlight any group of cells in a worksheet and run a
macro that will calculate the average of the cell values. I want this
average value to pop up in a small window that I can immediately close and do
again and again. I realize that this will probably require some programming
in VB. It seems relatively simple but I am not familiar enough with VB to
figure it out on my own.

ANY help would be greatly appreciated.

-CRA
 
You can accomplish this without VBA. Right-click on the
status bar at the bottom right-hand corner of your Excel
window and select "Average". Now select your range of
cells. The average will appear.

HTH
Jason
Atlanta, GA
 
Try this:

Sub mAverage()
Dim CellValue As Range
Dim RunningTotal As Double
For Each CellValue In Selection
RunningTotal = RunningTotal + CellValue
Next CellValue
If Selection.Count > 0 Then
MsgBox (RunningTotal / Selection.Count)
End If
End Sub

Art
 

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

Similar Threads


Back
Top