Hello, I am new to VBA.
I have the following code
Sub Backtest()
Dim myRange As Range
Dim a As Long
Dim i As Long, j As Long
Set myRange = Range("b3:b217")
For i = 1 To myRange.Rows.Count
Worksheets("backtesting").Range("b" & i + 2).Copy
Worksheets("izberi datum").Range("E3").PasteSpecial xlPasteValues
Worksheets("backtesting").Range("C" & i + 2) = Worksheets("var in mvar").Range("g12") * Worksheets("var in mvar").Range("j14")
a = Worksheets("backtesting").Range("C" & i + 2)
Worksheets("backtesting").Range("D" & i + 2) = Application.CountIf(Worksheets("donos_portfelja").Range("am4:am265"), "<" & a)
Next i
End Sub
My Count if function is not working. I receieve numbers but they are wrong. Is is possible there is a problem with decimals as the number a is around -0,008?
If I type in the number it works!
Thank you for your help...
Ana
I have the following code
Sub Backtest()
Dim myRange As Range
Dim a As Long
Dim i As Long, j As Long
Set myRange = Range("b3:b217")
For i = 1 To myRange.Rows.Count
Worksheets("backtesting").Range("b" & i + 2).Copy
Worksheets("izberi datum").Range("E3").PasteSpecial xlPasteValues
Worksheets("backtesting").Range("C" & i + 2) = Worksheets("var in mvar").Range("g12") * Worksheets("var in mvar").Range("j14")
a = Worksheets("backtesting").Range("C" & i + 2)
Worksheets("backtesting").Range("D" & i + 2) = Application.CountIf(Worksheets("donos_portfelja").Range("am4:am265"), "<" & a)
Next i
End Sub
My Count if function is not working. I receieve numbers but they are wrong. Is is possible there is a problem with decimals as the number a is around -0,008?
If I type in the number it works!
Thank you for your help...
Ana