My code is this:

Function calculoVR(datos As Range, tipos As Range, dolar As Double, uf As Double) Dim y As Integer y = 0 For Each x In tipos If x.Value = "Ch$ Real ('000)" Then calculoVR = calculoVR + datos(0, y) * 1000 / dolar y = y + 1 ElseIf x.Value = "UF" Then calculoVR = calculoVR + datos(0, y) * uf / dolar y = y + 1 ElseIf x.Value = "US" Then calculoVR = calculoVR + datos(0, y) y = y + 1 End If Next End Function

As far as I've been able to check, the "If" statements aren't checking correctly the value, hence not calculating the result.

Any help? The problem is a bit more complicated than this, but I don't wanna ramble too much :/