View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Keith R[_3_] Keith R[_3_] is offline
external usenet poster
 
Posts: 30
Default Need UDF help; cycling through various sheets using VBA name property

Thanks to Tom, Bob, and Mark for your responses. I had forgotten about the
application.volatile issue, so I went ahead and decided to pass the source
ranges directly. Here's the final product, in case anyone is interested :)
Keith R
XL97
================================================== ======
Public Function Consolidated(SC1 As Range, SC2 As Range, SC3 As Range, _
SC4 As Range, SC5 As Range, SC6 As Range, SC7 As Range) As Variant
'each input range will be a single cell

Dim i As Long
Dim ws As Range
Dim TotalValue As Double
Dim DivCount As Double

For i = 1 To 7
Set ws = (Choose(i, SC1, SC2, SC3, SC4, SC5, SC6, SC7))
If Not IsError(ws.Value) Then
If Not IsEmpty(ws.Value) Then
If IsNumeric(ws.Value) Then
TotalValue = TotalValue + ws.Value
DivCount = DivCount + 1
End If
End If
End If
Next
If DivCount 0 Then
Consolidated = TotalValue / DivCount
Else
Consolidated = CVErr(xlErrNA)
End If

End Function