VBA Count if function ("<")

anusa

New Member
Joined
Aug 11, 2015
Messages
4
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
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Watch MrExcel Video

Forum statistics

Threads
1,095,352
Messages
5,443,959
Members
405,257
Latest member
daveyf

This Week's Hot Topics

Top