Using the Select Case Statement to check the function parameter
Sub DisplayDiscount()
Dim unitsSold As Integer
Dim myDiscount As Single
unitsSold = InputBox("Enter the number of sold units:")
myDiscount = GetDiscount(unitsSold)
MsgBox myDiscount
End Sub
Function GetDiscount(unitsSold As Integer)
Select Case unitsSold
Case 1 To 200
GetDiscount = 0.05
Case 201 To 500
GetDiscount = 0.1
Case 501 To 1000
GetDiscount = 0.15
Case Is > 1000
GetDiscount = 0.2
End Select
End Function