Bom Dia,
Obrigado pelas respostas, mas ainda não consegui.
Aqui está o código todo, meu problema se encontra em negrito, pois quando tento gravar a formula em VBA usando F2, ele muda de linha por conta do tamanho, e perde partes da fórmula.
Attribute VB_Name = "Módulo1"
Dim RefreshDate As Date
Sub Start()
RefreshDate = Now + TimeValue("00:00:30")
Application.OnTime RefreshDate, "Atualizar"
End Sub
Sub Atualizar()
If Plan1.Cells(5, 1).Value = True Then
Plan1.Cells(2, 3).Value = TimeValue(Now)
Call Start
Else
Exit Sub
End If
If Plan1.Cells(2, 2).Value < (TimeValue(Now) - TimeValue("00:01:30")) Then 'No exemplo executa a macro a cada 10 segundos
Plan1.Cells(2, 2).Value = TimeValue(Now)
Application.Run "BloombergUI.xla!WorksheetRefresh"
Else
End If
Plan5.Cells(2, 1).Value = TimeValue(Now)
If Plan5.Cells(2, 2).Value < (TimeValue(Now) - TimeValue("00:01:00")) Then 'No exemplo executa a macro a cada 10 segundos
Plan5.Cells(2, 2).Value = TimeValue(Now)
Plan5.PivotTables("Tabela dinâmica1").PivotCache.Refresh
Else
End If
End Sub
Sub SendCall()
Dim Ln_Active As String
Dim LnTot_Calls As String
Dim NextLn_open As String
Dim a, b, c, d, e, f, g, h, i, j, k, l As Long
Sheets("Sugestões").Select
'Não estou validando se este mesmo call já não enviado.
Ln_Active = ActiveCell.Offset(0, 0).Row
LnTot_Calls = ActiveSheet.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count - 3
If Ln_Active <= 4 Or Ln_Active > LnTot_Calls + 4 Then
MsgBox ("Selecione uma Operação válida! ")
Exit Sub
Else
End If
If MsgBox("Deseja Enviar a Recomendação de: " & Sheets("Sugestões").Range("B" & Ln_Active).Value & " " & Sheets("Sugestões").Range("A" & Ln_Active).Value & " ?", vbYesNo) = vbYes Then
Else
Exit Sub
End If
a = ActiveSheet.Cells(Ln_Active, 1).Value
b = ActiveSheet.Cells(Ln_Active, 2).Value
c = ActiveSheet.Cells(Ln_Active, 3).Value
d = ActiveSheet.Cells(Ln_Active, 4).Value
e = ActiveSheet.Cells(Ln_Active, 5).Value
f = ActiveSheet.Cells(Ln_Active, 6).Value
g = ActiveSheet.Cells(Ln_Active, 7).Value
h = ActiveSheet.Cells(Ln_Active, 8).Value
i = ActiveSheet.Cells(Ln_Active, 9).Value
j = ActiveSheet.Cells(Ln_Active, 10).Value
k = ActiveSheet.Cells(Ln_Active, 11).Value
m = ActiveSheet.Cells(Ln_Active, 12).Value
n = ActiveSheet.Cells(Ln_Active, 13).Value
o = ActiveSheet.Cells(Ln_Active, 14).Value
NextLn_open = Worksheets("abertas").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
Worksheets("abertas").Cells(8 + NextLn_open, 1).Value = a
Worksheets("abertas").Cells(8 + NextLn_open, 2).Value = b
Worksheets("abertas").Cells(8 + NextLn_open, 3).Value = j
Worksheets("abertas").Cells(8 + NextLn_open, 4).FormulaR1C1 = "=IF(RC[-2]=""venda"",BDP(RC[-3]&"" bz equity"",""bid""),BDP(RC[-3]&"" bz equity"",""Ask""))"
Worksheets("abertas").Cells(8 + NextLn_open, 5).FormulaR1C1 = "=IF(RC[-3]=""compra"",RC[-1]/RC[-2]-1,-(RC[-1]/RC[-2]-1))"
Worksheets("abertas").Cells(8 + NextLn_open, 6).FormulaR1C1 = "=IF(RC[-4]=""compra"",ROUNDDOWN(RC[16],2),ROUNDUP(RC[16],2))"
Worksheets("abertas").Cells(8 + NextLn_open, 7).FormulaR1C1 = "=IF(RC[-5]=""compra"",RC[-1]/RC[-4]-1,-(RC[-1]/RC[-4]-1))"
Worksheets("abertas").Cells(8 + NextLn_open, 8).FormulaR1C1 = "=IF(RC[-6]=""compra"",ROUNDDOWN(RC[15],2),ROUNDUP(RC[15],2))"
Worksheets("abertas").Cells(8 + NextLn_open, 9).FormulaR1C1 = "=IF(RC[-7]=""compra"",RC[-1]/RC[-6]-1,-(RC[-1]/RC[-6]-1))"
Worksheets("abertas").Cells(8 + NextLn_open, 10).Value = c
Worksheets("abertas").Cells(8 + NextLn_open, 11).Value = d
Worksheets("abertas").Cells(8 + NextLn_open, 12).Value = e
Worksheets("abertas").Cells(8 + NextLn_open, 13).Value = f
Worksheets("abertas").Cells(8 + NextLn_open, 14).Value = g
[b]Worksheets("abertas").Cells(8 + NextLn_open, 15).FormulaR1C1 = "=IF(IF(AND(RC[-13]=""compra"",RC[-12]>RC[4],RC[5]>RC[-7]),""Aguardando"",IF(AND(RC[-13]=""compra"",RC[-12]>RC[4],RC[5]<RC[-7]),""Cancelado"",IF(AND(RC[-13]=""venda"",RC[-12]<RC[5],RC[-7]>RC[4]),""Aguardando"",IF(AND(RC[-13]=""venda"",RC[-12]<RC[5],RC[4]>RC[-7]),""Cancelado"",""Aberto""))))=""Aberto"",IF(AND(RC[-13]=""compra"",RC[-11]<RC[-9],RC[-11]>RC[-7]),""Em Andamento"",IF(AND(RC[-13]=""compra"",RC[-11]>=RC[-9]),""Concluído"",IF(AND(RC[-13]=""compra"",RC[-11]<=RC[-7]),""STOP"",IF(AND(RC[-13]=""venda"",RC[-11]>RC[-9],RC[-11]<RC[-7]),""Em Andamento"",IF(AND(RC[-13]=""venda"",RC[-11]<=RC[-9]),""Concluído"",IF(AND(RC[-13]=""venda"",RC[-11]>=RC[-7]),""STOP"")))))),IF(AND(RC[-13]=""compra"",RC[-12]>RC[4],RC[5]>RC[-7]),""Aguardando"",IF(AND(RC[-13]=""compra"",RC[-12]>RC[4],RC[5]<RC[-7]),""Cancelado"",IF(AND(RC[-13]=""venda"",RC[-12]<RC[5],RC[-7]>RC[4]),""Aguardando"",IF(AND(RC[-13]=""venda"",RC[-12]<RC[5],RC[4]>RC[-7]),""Cancelado"")))))"[/b]
Worksheets("abertas").Cells(8 + NextLn_open, 16).Value = h
Worksheets("abertas").Cells(8 + NextLn_open, 17).Value = n
Worksheets("abertas").Cells(8 + NextLn_open, 18).Value = o
Worksheets("abertas").Cells(8 + NextLn_open, 19).FormulaR1C1 = "=BDP(RC[-18]&"" bz equity"",""high"")"
Worksheets("abertas").Cells(8 + NextLn_open, 20).FormulaR1C1 = "=BDP(RC[-19]&"" bz equity"",""LOW"")"
Worksheets("abertas").Cells(8 + NextLn_open, 21).FormulaR1C1 = "=IF(AND(RC[-2]<>RC[-4],RC[-3]<>RC[-1]),""mudoutdo"",IF(RC[-2]<>RC[-4],""mudoumax"",IF(RC[-3]<>RC[-1],""mudoumin"",""-"")))"
Worksheets("abertas").Cells(8 + NextLn_open, 22).Value = k
Worksheets("abertas").Cells(8 + NextLn_open, 23).Value = m
Worksheets("Email Envio").Cells(17, 2).Value = a
Worksheets("Email envio").Cells(17, 3).Value = b
Worksheets("Email envio").Cells(18, 3).Value = j
Worksheets("Email envio").Cells(19, 3).Value = k
Worksheets("Email envio").Cells(20, 3).Value = m
EmailEnvio
End Sub
A fórmula que eu preciso que vá na célula é esta:
=SE(SE(E(LC[-13]="compra";LC[-12]>LC[4];LC[5]=LC[3]);"Aguardando";SE(E(LC[-13]="compra";LC[-12]>LC[4];LC[5]<LC[-7];LC[5]<LC[3]);"Cancelado";SE(E(LC[-13]="venda";LC[-12]<LC[5];LC[2]=LC[4]);"Aguardando";SE(E(LC[-13]="venda";LC[-12]<LC[5];LC[4]>LC[-7]);"Cancelado";"Aberto"))))="Aberto";SE(SE(E(LC[-13]="compra";LC[6]="mudoumax";LC[4]<LC[-9];LC[-11]>LC[-7]);"Em Andamento";SE(E(LC[-13]="compra";LC[6]="mudoumin";LC[5]>LC[-7];LC[-11]<LC[-9]);"Em Andamento";SE(LC[6]="mudoutdo";"Atenção";"-")))="Em andamento";"Em andamento";SE(SE(E(LC[-13]="venda";LC[6]="mudoumax";LC[4]<LC[-7]);"Em Andamento";SE(E(LC[-13]="venda";LC[6]="mudoumin";LC[5]>LC[-9];LC[-11]<LC[-7]);"Em Andamento";SE(LC[6]="mudoutdo";"Atenção";"-")))="Em andamento";SE(E(LC[-13]="venda";LC[-11]>LC[-9];LC[-11]<LC[-7]);"Em Andamento");SE(OU(E(LC[-13]="compra";LC[-11]>=LC[-9]);E(LC[-13]="compra";LC[4]>LC[2];LC[4]>=LC[-9]));"Concluído";SE(E(LC[-13]="compra";LC[-11]<=LC[-7]);"STOP";SE(E(LC[-13]="compra";LC[5]<=LC[-7];LC[5]<LC[3];LC[5]<>LC[3]);"STOP";SE(OU(E(LC[-13]="venda";LC[-11]<=LC[-9]);E(LC[-13]="venda";LC[5]<LC[3];LC[5]<=LC[-9]));"Concluído";SE(E(LC[-13]="venda";LC[-11]>=LC[-7]);"STOP";SE(E(LC[-13]="venda";LC[4]>=LC[-7];LC[4]<>LC[2]);"STOP"))))))));SE(E(LC[-13]="compra";LC[-12]>LC[4];LC[5]=LC[3]);"Aguardando";SE(E(LC[-13]="compra";LC[-12]>LC[4];LC[5]<LC[-7];LC[5]<LC[3]);"Cancelado";SE(E(LC[-13]="venda";LC[-12]<LC[5];LC[2]=LC[4]);"Aguardando";SE(E(LC[-13]="venda";LC[-12]<LC[5];LC[4]>LC[-7];LC[5]<LC[3]);"Cancelado")))))
Ela está funcionando normalmente. porém não consigo consertar as mudanças de linha e fazer com que ela continue funcionando.
Desde já agradeço a atenção