I want to create a function in my Excel workbook that converts all the cells in the three sheets I am currently using with a currency format from one currency (SLL) to another (DKK) by the click of a button (the same button converts in SLL or in DKK depending on which currency the values currently are in).
My code is:
Sub convertcurrency()
Dim userrate1 As Long
Dim userrate2 As Long
For Each cell In ActiveWorkbook.Worksheets
userrate1 = 625
If Cells.NumberFormat = "DKK" & "$ #,##0.00" _
Then cell.Value = "SLL" & userrate1 * cell.Value
ElseIf Cells.NumberFormat = "SLL" & "$ #,##0.00" _
Then cell.Value = "DKK" & (1 / userrate1) * cell.Value _
End If
End Sub
But it's not working. The error is "Compile error. Else without if". But how can I use else without if, if I need to include the second restriction.