I think this code will help you problem
Dim dStart As Date
Dim dEnd As Date
Dim dDate As Date
Dim iCol As Integer
iCol = 2
Do While Cells(iCol, 2).Value <> ""
dStart = Format(Cells(iCol, 2).Value, "mm/dd/yyyy")
dEnd = Format(Cells(iCol, 3).Value, "mm/dd/yyyy")
if dDate > dStart and dDate < dEnd then
if Cell(iCol,4).Value = "SELL" then
printout -1
else
printout 1
end if
else
printout 0
end if
iCol = iCol + 1
Loop
If you just only need excel function
=IF(AND(J3 >= F3,J3 <= G3, H3="SELL"),-1,IF(AND(J3 >= F3,J3 <= G3, H3="BUY"),1,0))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…