View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default NEED HELP with simple function

What exactly are you tying to test, and for what? Your code confuses me.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
This is my first time ever programming with VBA and I figured that
creating a function that sums up the number of items that fit a couple
of criteria wouldn't be very hard. However, this is proving to be more
difficult for me than I thought. This is what I have, but it returns a
#VALUE! error in the hosting cell:

Function OtherINLDue(INL1() As String, Category1() As String, INL2() As
String, Category2() As String)

Dim i As Integer
Dim totalDue As Integer

For i = 0 To UBound(INL1)

If Category1(i) = "LN2" Or Category1(i) = "LN4" Then
If UPPER(Left(INL1(i), 3)) < "EKT" And UPPER(Left(INL1(i), 2))
< "NT" And UPPER(Left(INL1(i), 2)) < "TM" And UPPER(Left(INL1(i), 2))
< "FC" And UPPER(Left(INL1(i), 5)) < "WFFOD" And UPPER(Left(INL1(i),
5)) < "CEDDS" And UPPER(Left(INL1(i), 4)) < "PROD" And
UPPER(Left(INL1(i), 2)) < "SM" And UPPER(Left(INL1(i), 2)) < "SS" And
UPPER(Left(INL1(i), 2)) < "TS" Then
totalDue = totalDue + 1
End If

Next i

For i = 0 To UBound(INL2)

If Category2(i) = "LN2" Or Category2(i) = "LN4" Then
If UPPER(Left(INL2(i), 3)) < "EKT" And UPPER(Left(INL2(i), 2))
< "NT" And UPPER(Left(INL2(i), 2)) < "TM" And UPPER(Left(INL2(i), 2))
< "FC" And UPPER(Left(INL2(i), 5)) < "WFFOD" And UPPER(Left(INL2(i),
5)) < "CEDDS" And UPPER(Left(INL2(i), 4)) < "PROD" And
UPPER(Left(INL2(i), 2)) < "SM" And UPPER(Left(INL2(i), 2)) < "SS" And
UPPER(Left(INL2(i), 2)) < "TS" Then
totalDue = totalDue + 1
End If

Next i

OtherINLDue = totalDue

End Function

Any Help would be appreciated