Currency Converter

New Contributor

Hello

 

I'd like to create a function that reads the currency and converts it into a prefered currency if necessary.

For example, I have a table that includes a column with prices in different currencies (CHF and €).

If the price is in Euro I want it to be converted into CHF according to the defined exchange rate.

So far I got the following code:

 

Function EURO2CHF(Euro, Kurs)
If Euro.NumberFormat = "€" Then
EURO2CHF = Euro * Kurs
ElseIf Euro.NumberFormat = "CHF" Then
EURO2CHF = Euro * 1
End If
End Function

 

Does any one know why this is not working properly? As a solution I always get CHF -, so it converts the currency but it doesn't do the math.

 

Thanks for any advices

1 Reply

@ExcelDIY Any particular reason why you want to use a User Defined Function for this kind of basic operation? A simple IF statement will do. See picture below.

Screenshot 2021-02-10 at 10.22.22.png