NEED HELP with simple function

  • Thread starter Bernadette.Nicholas
  • Start date
B

Bernadette.Nicholas

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top