I've made a sample function which calculates cartage based on country and weight, and I would like the country to appear as a drop-down list. It's like what you can see when using Subtotal
function, so users can select from when they entering the formula in cells.
I have referred to this question and answer: VBA Function argument list select
The function worked only if the reference number of enumeration entered as the first argument, and it's not taking cell value.
May I ask:
Is it possible the enumeration descriptive value be shown as a drop-down list like the
Subtotal
function?Is it possible the first argument take value from the cell as per users assigned?
Here is sample code:
Option Explicit
Public Enum nations
USA = 1
AU = 2
CN = 3
SG = 4
End Enum
Function intlCartage(country As nations, weight As Double)
Select Case country
Case nations.AU
intlCartage = 15 + WorksheetFunction.RoundUp((weight - 1), 0) * 10
Case nations.CN
intlCartage = 20 + WorksheetFunction.RoundUp((weight - 1), 0) * 5
Case nations.SG
intlCartage = 15 + WorksheetFunction.RoundUp((weight - 1), 0) * 10
Case nations.USA
intlCartage = 10 + WorksheetFunction.RoundUp((weight - 1), 0) * 8
Case Else
intlCartage = "please contact sales for quote."
End Select
End Function