LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a new function

I'm trying to create a function to help determine rates.

There are four cells to be examined, and based on the selection of the
four cells, it will spit out a value in another cell.
The first cell, choice is Single or Family
second, third and fourth cell, all have a choice of A, B or C.

The problem is what I plunk this function into a cell in the
spreadsheet, I get a "#VALUE" error. I'm VERY new to VB, and I'm
hoping someone out there could help me out. Any help would be greatly
appreciated.

Here's what I have:

Function Benefits(Selection, Health, Dental, Drug As String)
Dim TotalHealth, TotalDental, TotalDrug As Integer
Dim SHealthA, SHealthB, SHealthC As Integer
Dim SDentalA, SDentalB, SDentalC As Integer
Dim SDrugA, SDrugB, SDrugC As Integer
Dim FSHealthA, FHealthB, FHealthC As Integer
Dim FSDentalA, FDentalB, FDentalC As Integer
Dim FSDrugA, FDrugB, FDrugC As Integer
Dim Benefit As Integer

'Rate Table (Single)
SHealthA = "insert rates here"
SHealthB = "insert rates here"
SHealthC = "insert rates here"
'etc., as dim'd above.

'Rate Table (Family)
FHealthA = "insert rates here"
FHealthB = "insert rates here"
FHealthC = "insert rates here"
'etc., as dim'd above.

'Single
If Selection = "Single" Then
'Health Selection
If Health = "A" Then
TotalHealth = SHealthA
ElseIf Health = "B" Then
TotalHealth = SHealthB
Else
TotalHealth = SHealthC
End If
'Dental Selection
If Dental = "A" Then
TotalDental = SDentalA
ElseIf Dental = "B" Then
TotalDental = SDentalB
Else
TotalDental = SDentalC
End If
'Drug Selection
If Drug = "A" Then
TotalDrug = SDrugA
ElseIf Drug = "B" Then
TotalDrug = SDrugB
Else
TotalDrug = SDrugC
End If

'Family
Else
'Health Selection
If Health = "A" Then
TotalHealth = FHealthA
ElseIf Health = "B" Then
TotalHealth = FHealthB
Else
TotalHealth = FHealthC
End If
'Dental Selection
If Dental = "A" Then
TotalDental = FDentalA
ElseIf Dental = "B" Then
TotalDental = FDentalB
Else
TotalDental = FDentalC
End If
'Drug Selection
If Drug = "A" Then
TotalDrug = FDrugA
ElseIf Drug = "B" Then
TotalDrug = FDrugB
Else
TotalDrug = FDrugC
End If

End If
'Calculation
Benefit = TotalHealth + TotalDrug + TotalDental
ActiveCell.Value = Benefit
End Function
 
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
Help with creating a function Craig Excel Worksheet Functions 4 February 2nd 09 09:51 PM
Creating a Function Stu Gnu[_2_] Excel Worksheet Functions 4 August 31st 07 08:44 AM
Creating a Function Stu Gnu[_2_] Excel Worksheet Functions 2 August 30th 07 11:47 AM
Creating a Function yanf7[_3_] Excel Programming 1 September 28th 04 06:02 PM
Creating a function Todd Huttenstine[_2_] Excel Programming 15 December 5th 03 11:38 PM


All times are GMT +1. The time now is 07:29 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"