ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Case Information Needed (https://www.excelbanter.com/excel-programming/290383-select-case-information-needed.html)

Richard Larson

Select Case Information Needed
 
I use the following function to calculate discounts on sales volumes. It
works but will still accept entries other than integers and will usually
show a 30% discount! The last message box must have a syntax error also....
Any help would be appreciated....TIA


Function CCDiscount(ContractValue)
Select Case ContractValue
Case Is < 0
CCDiscount = "Error < 0"
Case Is < 24000
CCDiscount = 0
Case Is < 33000
CCDiscount = 0.03
Case Is < 60000
CCDiscount = 0.05
Case Is < 120000
CCDiscount = 0.09
Case Is < 210000
CCDiscount = 0.15
Case Is < 600000
CCDiscount = 0.2
Case Is = 600000
CCDiscount = 0.3
Case Else
CCDiscount = "Error"
End Select
End Function




Tom Ogilvy

Select Case Information Needed
 
possibly

Function CCDiscount(ContractValue)
Select Case clng(ContractValue)
Case Is < 0
CCDiscount = "Error < 0"
Case Is < 24000
CCDiscount = 0
Case Is < 33000
CCDiscount = 0.03
Case Is < 60000
CCDiscount = 0.05
Case Is < 120000
CCDiscount = 0.09
Case Is < 210000
CCDiscount = 0.15
Case Is < 600000
CCDiscount = 0.2
Case Is = 600000
CCDiscount = 0.3
Case Else
CCDiscount = "Error"
End Select
End Function

--
Regards,
Tom Ogilvy


"Richard Larson" wrote in message
...
I use the following function to calculate discounts on sales volumes. It
works but will still accept entries other than integers and will usually
show a 30% discount! The last message box must have a syntax error

also....
Any help would be appreciated....TIA


Function CCDiscount(ContractValue)
Select Case ContractValue
Case Is < 0
CCDiscount = "Error < 0"
Case Is < 24000
CCDiscount = 0
Case Is < 33000
CCDiscount = 0.03
Case Is < 60000
CCDiscount = 0.05
Case Is < 120000
CCDiscount = 0.09
Case Is < 210000
CCDiscount = 0.15
Case Is < 600000
CCDiscount = 0.2
Case Is = 600000
CCDiscount = 0.3
Case Else
CCDiscount = "Error"
End Select
End Function







All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com