Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default Custom or VBA Function for Avg, Std, Min, Max

Does anyone know of any code for custom functions or VBA functions for Avg,
Std, Min, Max? I had been using the Excel functions (i.e.
application.worksheetfunction.) but have run into the 65326 contraint when
trying to apply these to an array populated by an Excel range. I need to
pass the VBA array to these VBA functions to get the Avg, Std, Min, Max.

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Custom or VBA Function for Avg, Std, Min, Max

Without knowing how your spreadsheet is set up and whether you're trying to
get stats for columns of info or rows of info, or for a matrix it's hard to
provide specific code.
One starting point I can think of is that you could select all the cells
involved and call a macro which gets the .Address of the current selection.
You can then quickly examine the address and determine the number of
rows/columns and continue on to calculate stats within that range. In Excel
VBA Selection.Address will return something like $A$1:$A$29 if you just
select a single row of cells (A1 through A29) and it will return something
like $A$1:$D$44 if you were to select all of those cells.

Now I could code up something to get AVG, MIN and MAX, but I'd have to look
up formula somewhere to code the equivalent of STD, unless you have it laying
around handy somewhere. I'm not a statistician.

here's some code that will take the selected range and parse out start/end
columns and row numbers:
Sub ParseAddress()
Dim RangeAddress As String
Dim FirstColumn As String
Dim FirstRow As Long
Dim LastColumn As String
Dim LastRow As Long

With Selection
MsgBox "The address is: " & .Address
End With
RangeAddress = Selection.Address
' $A$4:$D$99
FirstColumn = Mid(RangeAddress, 2, InStr(2, RangeAddress, "$") - 2)
MsgBox "First Column is: " & FirstColumn
'rip off what we just found
RangeAddress = Right(RangeAddress, Len(RangeAddress) - (Len(FirstColumn)
+ 2))
MsgBox "RangeAddress Reduced to: " & RangeAddress
FirstRow = Val(Left(RangeAddress, InStr(RangeAddress, ":") - 1))
MsgBox "First Row is: " & FirstRow
'again rip off what has been extracted
RangeAddress = Right(RangeAddress, Len(RangeAddress) -
InStr(RangeAddress, ":"))
MsgBox "RangeAddress reduced to: " & RangeAddress
LastColumn = Mid(RangeAddress, 2, InStr(2, RangeAddress, "$") - 2)
MsgBox "Last Column is: " & LastColumn
LastRow = Val(Right(RangeAddress, Len(RangeAddress) - InStr(2,
RangeAddress, "$")))
MsgBox "Last Row is: " & LastRow
End Sub

"ExcelMonkey" wrote:

Does anyone know of any code for custom functions or VBA functions for Avg,
Std, Min, Max? I had been using the Excel functions (i.e.
application.worksheetfunction.) but have run into the 65326 contraint when
trying to apply these to an array populated by an Excel range. I need to
pass the VBA array to these VBA functions to get the Avg, Std, Min, Max.

Thanks

EM

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 02:40 AM
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
Custom function to simplify Index(match)) formula Martin Excel Discussion (Misc queries) 0 March 20th 06 02:45 PM
Custom Function SPeterson Excel Discussion (Misc queries) 3 December 21st 05 07:12 PM
Custom function returning VALUE error alex.k Excel Discussion (Misc queries) 6 September 27th 05 03:05 AM


All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"