View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Erin[_5_] Erin[_5_] is offline
external usenet poster
 
Posts: 19
Default UDF's and Worksheet Function VBA Combinations

Here is one for your second function:

Function IfFunction(Range1, Range2, Range3)
Dim BlnSameSize As Boolean
Dim dblArray() As Double

On Error GoTo ErrRtn
BlnSameSize = False
If Range1.Cells.Count = Range2.Cells.Count And
Range2.Cells.Count = Range3.Cells.Count Then BlnSameSize =
True
If Not BlnSameSize Then GoTo ErrRtn
ReDim dblArray(Range1.Cells.Count - 1)
For i = 1 To Range1.Cells.Count
If Range1.Cells(i) = "AA" And Range2.Cells(i) <=
#8/31/2004# And Range2.Cells(i) = #8/1/2004# And
Range3.Cells(i) = "DD" Then
dblArray(i - 1) = 1
Else
dblArray(i - 1) = 0
End If
Next i
IfFunction = WorksheetFunction.Sum(dblArray)
Exit Function

ErrRtn:
IfFunction = CVErr(xlErrValue)
End Function

-----Original Message-----
Thank you so much that just shaved off so much time.
.