LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default New to functions, 'If' isn't working for me

Hi,
I am trying to write my first function. Tha aim is to add an extra column
and populate it with categories for each record. Hopefully the code below
will help in understanding:

Function undispatched_age_bucket(ByVal business, ByVal Paper_vs_Elec, ByVal
dispatch_age, ByVal credit_paper_benchmark, _
ByVal rates_paper_benchmark, ByVal gme_paper_benchmark, ByVal
other_paper_benchmark) As Variant

If IsNull(business) Or IsNull(Paper_vs_Elec) Or IsNull(dispatch_age)
Then credit_paper_benchmark = ""

If PapervsElec = "p" Then

If business = "Credit" And dispatch_age credit_paper_benchmark Then
undispatched_age_bucket = "" & credit_paper_benchmark
Else
undispatched_age_bucket = "<=" & credit_paper_benchmark
End If

If business = "Rates" And dispatch_age rates_paper_benchmark Then
undispatched_age_bucket = "" & rates_paper_benchmark
Else
undispatched_age_bucket = "<=" & rates_paper_benchmark
End If

If business = "GME" And dispatch_age gme_paper_benchmark Then
undispatched_age_bucket = "" & gme_paper_benchmark
Else
undispatched_age_bucket = "<=" & gme_paper_benchmark
End If

If business = "Other" And dispatch_age other_paper_benchmark Then
undispatched_age_bucket = "" & other_paper_benchmark
Else
undispatched_age_bucket = "<=" & other_paper_benchmark
End If

Else
IsNull (undispatched_age)
End If

End Function


I select the values for 'paper vs elec', 'business' and 'dispatch age' and
type in the values for the benchmarks. When I try to drag the field down it
simply repeats the first value it generates over and over and doesn't seem to
caculate a value.
Can anyone help??
Many thanks in advance.
-Ben
 
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
Excel FUNCTIONS stop working suekh Excel Worksheet Functions 3 July 10th 06 05:10 PM
Database functions should use criteria in formula, as 1-2-3 does 123user Excel Worksheet Functions 8 September 29th 05 08:57 PM
Changing the range of several averaging functions Hellion Excel Discussion (Misc queries) 1 September 17th 05 02:12 PM
Are there functions that perform robust statistics in Excel? froot_broot Excel Worksheet Functions 0 August 30th 05 10:18 PM
Application.Volatile not working as expected Richards Excel Discussion (Misc queries) 3 February 3rd 05 12:20 AM


All times are GMT +1. The time now is 07:05 PM.

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

About Us

"It's about Microsoft Excel"