LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default absolute maximum with sign

I made the following function from code in John Walkenbach's Excel
2003 Power Programming with VBA.

The problem I am having is when I use this function with an array
formula it returns a #VALUE! error. I've copied the formula below its
a little complex but the jest is that it tests if a few conditions are
true then returns an array of numbers.

=maxabs(((((Calculation!$G$87="Governing")+(Calcul ation!$G
$87=Risa_D))*((Calculation!$F$87="Governing")+(Cal culation!$F
$87=N(OFFSET(INDIRECT("'Risa Import'!$B$1"),ROW(Risa_D)-Risa_D,
0))))*((Calculation!$E$87="Governing")+(Calculatio n!$E
$87=T(OFFSET(INDIRECT("'Risa Import'!$C$1"),ROW(Risa_D)-Risa_D,
0))))*(ROW(Risa_D)))0)*Risa_J)*on

Risa_D is a named range that equals something like indirect("Range")
where "Range" is located on another sheet.

Function MaxAbs(ParamArray args() As Variant) As Variant

' Variable declarations
Dim i As Variant
Dim TempRange As Range, cell As Range
Dim ECode As String
MaxAbs = 0

' Process each argument
For i = LBound(args) To UBound(args)
' Skip missing arguments
If Not IsMissing(args(i)) Then
' What type of argument is it?
Select Case TypeName(args(i))
Case "Range"
' Create temp range to handle full row or column ranges
Set TempRange = Intersect(args(i).Parent.UsedRange, args(i))
For Each cell In TempRange
Select Case TypeName(cell.Value)
Case "Double"
If Abs(cell.Value) Abs(MaxAbs) Then _
MaxAbs = cell.Value
Case "String"
'MySum = MySum + Evaluate(cell.Value)
Case "Error"
Select Case cell.Text
Case "#DIV/0!"
MaxAbs = CVErr(xlErrDiv0)
Case "#N/A"
MaxAbs = CVErr(xlErrNA)
Case "#NAME?"
MaxAbs = CVErr(xlErrName)
Case "#NULL!"
MaxAbs = CVErr(xlErrNull)
Case "#NUM!"
MaxAbs = CVErr(xlErrNum)
Case "#REF!"
MaxAbs = CVErr(xlErrRef)
Case "#VALUE!"
MaxAbs = CVErr(xlErrValue)
End Select
Exit Function
Case "Date"
If Abs(cell.Value) Abs(MaxAbs) Then _
MaxAbs = cell.Value
Case "Empty"
Case "Boolean"
If cell.Value = "True" Then _
If 1 Abs(MaxAbs) Then _
MaxAbs = 1
Case Else
If Abs(args(i)) Abs(MaxAbs) Then _
MaxAbs = args(i)
End Select
Next cell
Case "Null" 'ignore it
Case "Error" 'return the error
MaxAbs = args(i)
Exit Function
Case "Boolean"
' Check for literal TRUE and compensate
If args(i) = "True" Then _
If 1 Abs(MaxAbs) Then _
MaxAbs = 1
Case "Date"
If Abs(args(i)) Abs(MaxAbs) Then _
MaxAbs = args(i)
Case Else
If Abs(args(i)) Abs(MaxAbs) Then _
MaxAbs = args(i)
End Select
End If
Next i
End Function

I do have a function that works but it only works for this case and
not for other cases I need this function for.

Function MAXABS(rng)

Dim MaxVal, MinVal

MaxVal = WorksheetFunction.Max(rng)
MinVal = WorksheetFunction.Min(rng)

MAXABS = IIf(MaxVal < Abs(MinVal), MinVal, MaxVal)

End Function

Any help would be great.

 
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
Maximum Absolute values HW Excel Worksheet Functions 3 September 23rd 08 07:37 PM
how can i change dollar sign to rupee sign in sales invoice vishal kohli Excel Discussion (Misc queries) 3 May 10th 07 02:06 PM
$ sign for absolute reference Explanation pano Excel Worksheet Functions 3 February 14th 07 03:28 PM
How do I get the maximum absolute value of a range of numbers? biscuitsmom Excel Discussion (Misc queries) 2 January 19th 06 07:55 PM
Maximum Absolute with sign bramweisman[_3_] Excel Programming 2 January 29th 04 10:25 PM


All times are GMT +1. The time now is 07:19 AM.

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

About Us

"It's about Microsoft Excel"