Você está na página 1de 9

Sub analise()

Dim q As Double

Dim num As Double

Dim mul As Double

Dim abc As Double

Dim comp As Double

Dim nome As String

Dim posicao As String

Dim hoje As Date

Dim lin As Integer

Dim lina As Integer

Dim cod As String

Dim K20 As String

Dim M20 As String

Dim J20 As String

lin = 2

lina = 1

While Cells(lin, 22) <> Empty

'Analise de renda fixa

'principal

If Cells(lin, 28) = 0 Then

q = CInt(Cells(lin, 29))
End If

If Cells(lin, 28) > 0 Then

q = Cells(lin, 28)

End If

comp = CLng(Cells(lin, 35))

num = Cells(lin, 31)

mul = CLng(q * num)

abc = comp - mul

If abc <> 0 Then

nome = Cells(lin, 22)

tipo = Cells(1, 35)

Data = Cells(lin, 26)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em renda fixa, encontramos uma


inconsistência no ativo " & nome & ", operado em " & Data & ",em relação ao" & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

lin = 2

'Valor Financeiro disp

While Cells(lin, 22) <> Empty


q = CInt(Cells(lin, 28))

comp = CLng(Cells(lin, 37))

num = Cells(lin, 33)

mul = CLng(q * num)

abc = comp - mul

If abc <> 0 Then

nome = Cells(lin, 22)

tipo = Cells(1, 37)

Data = Cells(lin, 26)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em renda fixa, encontramos uma


inconsistência no ativo " & nome & ", operado em " & Data & ",em relação ao " & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

lin = 2

'valor financeiro em garantias

While Cells(lin, 22) <> Empty

q = CInt(Cells(lin, 29))

comp = CLng(Cells(lin, 38))


num = Cells(lin, 33)

mul = CLng(q * num)

abc = comp - mul

If abc <> 0 Then

nome = Cells(lin, 22)

tipo = Cells(1, 38)

Data = Cells(lin, 26)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em renda fixa, encontramos uma


inconsistência no ativo " & nome & ", operado em " & Data & ",em relação ao" & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

lin = 12

'analise acoes

'valor financeiro disponível

While Cells(lin, 53) <> Empty

q = CInt(Cells(lin, 56))

comp = CLng(Cells(lin, 59))


num = Cells(lin, 62)

mul = CLng(q * num)

abc = comp - mul

If abc <> 0 Then

nome = Cells(lin, 53)

tipo = Cells(1, 59)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em ações, encontramos uma inconsistência no


ativo " & nome & " em relação ao" & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

'valor em garantias

lin = 12

While Cells(lin, 53) <> Empty

q = CInt(Cells(lin, 58))

comp = CLng(Cells(lin, 60))

num = Cells(lin, 62)

mul = CLng(q * num)

abc = comp - mul


If abc <> 0 Then

nome = Cells(lin, 53)

tipo = Cells(1, 60)

posicao = Cells(lin, 65)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em ações, encontramos uma inconsistência no


ativo " & nome & " , em posição " & posicao & ", em relação ao" & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

'Análise de opções

lin = 15

While Cells(lin, 69) <> Empty

q = CInt(Cells(lin, 73))

comp = CLng(Cells(lin, 74))

num = Cells(lin, 79)

mul = CLng(q * num)

abc = comp - mul


If abc <> 0 Then

nome = Cells(lin, 69)

tipo = Cells(1, 74)

posicao = Cells(lin, 77)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em opções, encontramos uma inconsistência


no ativo " & nome & ", na posição " & posicao & " , em relação ao " & tipo & "."

lina = lina + 1

End If

lin = lin + 1

Wend

'Analise de futuros

'Análise de final de contrato

K20 = "K20"

J20 = "J20"

M20 = "M20"

lin = 19

While Cells(lin, 85) <> Empty


cod = Cells(lin, 88)

nome = Cells(lin, 85)

If cod = K20 Then

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em futuros, verificamos que o contrato " &
nome & ", de vencimento " & cod & " , já foi terminado."

lina = lina + 1

End If

If cod = J20 Then

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em futuros, verificamos que o contrato " &
nome & ", de vencimento " & cod & " , já foi terminado."

lina = lina + 1

End If

lin = lin + 1

Wend

'análise de valor indevido

lin = 19

While Cells(lin, 85) <> Empty

If Cells(lin, 89) = 0 Then


If Cells(lin, 92) <> 0 Then

nome = Cells(lin, 85)

cod = Cells(lin, 88)

tipo = Cells(1, 93)

posicao = Cells(lin, 94)

Worksheets(2).Cells(lina, 1) = "Analisando suas posições em futuros, encontramos uma inconsistência


no ativo " & nome & ", na posição " & posicao & " e no vencimento " & cod & ", que não deveria
receber mais alterações de " & tipo & "."

lina = lina + 1

End If

End If

lin = lin + 1

Wend

MsgBox ("A Análise terminou. Se o programa encontrou alguma incongruência de posições, tais
achados serão dispostos na worsheet(2)")

End Sub

Você também pode gostar