Alexandre, grato pelas informações!
Mas eu não conheço muito de VBA, faço as coisas meio que por engenharia reversa e procurando no Google, nunca estudei a fundo o tema...
Onde eu faria essa referência?
Att,
Lucão
Obs: Segue meu código do loop.
Sub nova()
htrade = range("htrade")
cont1 = range("cont1")
If cont1 = 1 Then
nova2
Exit Sub
End If
dolar = range("dolar")
htrade = range("htrade")
LINHA = range("linha")
range("a" & LINHA) = Time
range("b" & LINHA) = range("dolar")
range("c" & LINHA) = range("dolarl")
If range("linha").value > 82 Then
range("f" & LINHA) = range("risco")
range("e" & LINHA) = range("lotet")
End If
If range("linha").value > 86 Then
range("n" & LINHA) = range("g4")
range("o" & LINHA) = range("i2")
range("P" & LINHA) = range("D3")
range("n13") = range("d" & LINHA)
range("n14") = WorksheetFunction.Min(range(("d" & LINHA), ("d" & range("timi2"))))
range("n15") = WorksheetFunction.Max(range(("d" & LINHA), ("d" & range("timi2"))))
range("m" & LINHA) = range("dolarl") - Application.WorksheetFunction.Average(range(("c" & LINHA), ("c" & range("timi2"))))
range("i1") = WorksheetFunction.Average(range(("o" & LINHA), ("o" & range("timi2"))))
range("n7") = range("m" & LINHA)
range("n8") = WorksheetFunction.Min(range(("m" & LINHA), ("m" & range("timi2"))))
range("n9") = WorksheetFunction.Max(range(("m" & LINHA), ("m" & range("timi2"))))
range("c5") = WorksheetFunction.Average(range(("f" & LINHA), ("f" & range("timi2"))))
range("d" & LINHA) = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("timi2"))))
range("i10") = WorksheetFunction.Average(range(("c" & LINHA), ("c" & range("timi2"))))
range("p13") = WorksheetFunction.StDevP(range(("C" & LINHA), ("c" & range("timi2"))))
range("o13") = WorksheetFunction.StDevP(range(("b" & LINHA), ("b" & range("timi2"))))
range("t1") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("copl"))))
range("t2") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("timi2"))))
range("t3") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("a8"))))
range("t4") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("copl"))))
range("t5") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("timi2"))))
range("t6") = range("dolar") - Application.WorksheetFunction.Average(range(("B" & LINHA), ("b" & range("a8"))))
range("t7") = Application.WorksheetFunction.Average(range(("d" & LINHA), ("d" & range("a7"))))
End If
If range("d8") <> 0 And range("d4") < TimeValue("00:00:05") Then
range("c13") = WorksheetFunction.Average(range(("c" & LINHA), ("c" & range("timi2"))))
range("f11") = range("linha")
Application.ScreenUpdating = False
range("e" & range("f12"), ("e" & range("f11"))) = "0"
range("f5") = range("dolar")
range("o" & range("f12"), ("o" & range("f14"))).Select
Selection.ClearContents
Application.ScreenUpdating = True
End If
If range("d8") = 0 And range("d4") < TimeValue("00:00:05") Then
range("c13") = WorksheetFunction.Average(range(("c" & LINHA), ("c" & range("timi2"))))
range("f11") = range("linha")
Application.ScreenUpdating = False
range("e" & range("f12"), ("e" & range("f11"))) = "0"
range("f5") = range("dolar")
range("o" & range("f12"), ("o" & range("f14"))).Select
Selection.ClearContents
Application.ScreenUpdating = True
End If
If range("d8") <> 0 And range("linha").value > 100 Then
range("c15") = Application.WorksheetFunction.Average(range(("e" & LINHA), ("e" & range("f11"))))
range("E10") = Application.WorksheetFunction.Average(range(("P" & LINHA), ("P" & range("f15"))))
range("E11") = Application.WorksheetFunction.Max(range(("P" & LINHA), ("P" & range("f15"))))
range("E12") = Application.WorksheetFunction.Min(range(("P" & LINHA), ("P" & range("f15"))))
range("l3") = Time
range("i3") = Application.WorksheetFunction.Average(range(("n" & LINHA), ("n" & range("f11"))))
End If
If range("d8") = 0 And range("linha").value > 100 Then
range("k3") = Time
range("i3") = Application.WorksheetFunction.Average(range(("n" & LINHA), ("n" & range("f11"))))
range("c15") = Application.WorksheetFunction.Average(range(("e" & LINHA), ("e" & range("f11"))))
range("E10") = Application.WorksheetFunction.Average(range(("P" & LINHA), ("P" & range("f15"))))
range("E11") = Application.WorksheetFunction.Max(range(("P" & LINHA), ("P" & range("f15"))))
range("E12") = Application.WorksheetFunction.Min(range(("P" & LINHA), ("P" & range("f15"))))
End If
If range("n4") <> 0 Then
range("j" & LINHA) = range("n4")
End If
If range("m7") <> 0 Then
range("k" & LINHA) = range("m7")
End If
If range("m7") + range("n4") = 0 Then
range("i" & LINHA) = range("dolar")
End If
Dim y As range
Set y = range(("c" & LINHA), ("c80"))
Dim x As range
Set x = range(("b" & LINHA), ("b80"))
Dim Z As range
Set Z = range("tend")
Set w = range("dolar")
Dim a As Variant
a = Application.Trend(y, x, w)
Dim b As Variant
b = Application.Trend(y, x, Z)
range("g6").value = b
range("g7").value = a
range("h2") = Application.RSq(y, x)
If range("b1").value > 2 And range("linha").value > 180 Then
Application.Speech.Speak ("Azi")
range("d1") = range("agora")
range("a5") = range("dolarl")
range("a4") = range("dolar")
range("b3") = "C"
range("a3") = range("agora")
range("q" & LINHA) = range("dolar")
range("G11") = range("linha")
End If
If range("c1").value > 2 And range("linha").value > 180 Then
Application.Speech.Speak ("Lá")
range("e1") = range("agora")
range("a5") = range("dolarl")
range("a4") = range("dolar")
range("b3") = "V"
range("a3") = range("agora")
range("r" & LINHA) = range("dolar")
range("G11") = range("linha")
End If
range("linha") = LINHA + 1
Application.OnTime Now + TimeValue("00:00:01"), "nova"