+ Reply to Thread
Results 1 to 2 of 2

NEED HELP with simple function

Hybrid View

  1. #1

    NEED HELP with simple function

    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


  2. #2
    Bob Phillips
    Guest

    Re: 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)

    <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1