Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
COM Add-in - Simple Function Rasmus A Excel Programming 1 September 28th 05 02:25 PM
Simple Function HELP!!! Lori~[_2_] Excel Programming 1 September 18th 05 05:54 PM
simple if then function amy Excel Worksheet Functions 4 July 6th 05 05:36 PM
Simple Function Help ~ Please Avram Berman Excel Worksheet Functions 9 November 19th 04 11:01 PM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"