Notifications
Clear all

Colar valores

5 Posts
3 Usuários
0 Reactions
1,078 Visualizações
(@robertonl)
Posts: 0
New Member
Topic starter
 

Segue a duvida em relação a ficar os valores na célula e a formula permanece na macro.
Realizei todas as tentativas sem obter sucesso.

Sub Atualiza_Estoque()
'
' Atualiza_Lançamentos Macro
' Atualiza Informação de Estoque
'

Range("b4").Select
ActiveCell.Formula = "=vlookup(a4,cadastro!A:D,2,0)"
Range("a4").Select
Selection.End(xlDown).Select
lin = ActiveCell.Row
rg = "b4:b" & lin
ActiveCell.Value = ActiveCell.Value
Range("b4").Select
Selection.AutoFill Destination:=Range(rg), Type:=xlFillDefault

Range("c4").Select
ActiveCell.Formula = "=vlookup(a4,cadastro!A:D,3,0)"
Range("a4").Select
Selection.End(xlDown).Select
lin1 = ActiveCell.Row
rg1 = "c4:c" & lin1
ActiveCell.Value = ActiveCell.Value
Range("c4").Select
Selection.AutoFill Destination:=Range(rg1), Type:=xlFillDefault

Range("d4").Select
ActiveCell.Formula = "=vlookup(a4,cadastro!A:D,4,0)"
Range("a4").Select
Selection.End(xlDown).Select
lin2 = ActiveCell.Row
rg2 = "d4:d" & lin2
ActiveCell.Value = ActiveCell.Value
Range("d4").Select
Selection.AutoFill Destination:=Range(rg2), Type:=xlFillDefault
cont = 4

Do Until IsEmpty(Cells(cont, 2))
   If IsError(Cells(cont, 2)) Then
       Cells(cont, 2) = " "
   End If
    Range("E4").Select
    ActiveCell.Formula = "=SUMIF(Cadastro!a:e,A4,cadastro!e:e)+SUMIF(Lançamentos!F:G,""ENTRADA""&"" ""&A4,Lançamentos!G:G)-(SUMIF(Lançamentos!F:G,""SAIDA""&"" ""&A4,Lançamentos!G:G))"
    Range("A4").Select
    ActiveCell.Value = ActiveCell.Value
    Selection.End(xlDown).Select
    lin3 = ActiveCell.Row
    rg3 = "e4:e" & lin3
    ActiveCell.Value = ActiveCell.Value
    Range("e4").Select
    Selection.AutoFill Destination:=Range(rg3), Type:=xlFillDefault
    FinalRow = Cells(Rows.Count, 3).End(xlDown).Row
cont = cont + 1
    Loop
   FinalRow = Cells(Rows.Count, 3).End(xlUp).Row

On Error Resume Next
For I = 4 To FinalRow
    With Plan6
        If .Cells(I, 5) < .Cells(I, 3) Then
           '.Cells(I, 10) = J - (.Cells(I, 9) / .Cells(I, 7))
           .Cells(I, 6) = "Estoque Critico"
           '.Cells(I, 1) = " CRÍTICO "
           .Cells(I, 1).Resize(, 6).Interior.ColorIndex = 3
           .Cells(I, 1).Resize(, 11).Font.ColorIndex = 1
           .Cells(I, 1).Resize(, 6).Font.Bold = True
           Else
            If .Cells(I, 5) > .Cells(I, 4) Then
                '.Cells(I, 10) = (.Cells(I, 9) / .Cells(I, 8)) - J
                .Cells(I, 6) = "Estoque em Excesso"
                '.Cells(I, 1) = " "
                .Cells(I, 1).Resize(, 6).Interior.ColorIndex = 33
                .Cells(I, 1).Resize(, 6).Font.ColorIndex = 1
                .Cells(I, 1).Resize(, 6).Font.Bold = True
                Else
                 If .Cells(I, 5) > .Cells(I, 3) And .Cells(I, 5) < .Cells(I, 4) Then
                    .Cells(I, 6) = "Estoque Bom"
                    .Cells(I, 1).Resize(, 6).Interior.ColorIndex = 2
                    .Cells(I, 1).Resize(, 6).Font.Bold = True
                End If
            End If
        End If
    End With
Next I
'Call Macro1
'w.Protect senha
End Sub
 
Postado : 25/03/2018 11:22 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

e qual a duvida??

 
Postado : 26/03/2018 5:47 am
(@klarc28)
Posts: 0
New Member
 

Reinaldo, esse usuário tem outro tópico com a mesma dúvida.

 
Postado : 26/03/2018 5:53 am
(@robertonl)
Posts: 0
New Member
Topic starter
 

Tentei adaptar para colar somente valores nas células e a fórmula ficar na macro, porém quando consegui, ela mantem o valor da primeira linha até a ultima. Por esse motivo postei o código completo para ver se alguém possa dar-me uma luz na solução

 
Postado : 26/03/2018 7:34 am
(@robertonl)
Posts: 0
New Member
Topic starter
 

Tentei adaptar para colar somente valores nas células e a fórmula ficar na macro, porém quando consegui, ela mantem o valor da primeira linha até a ultima. Por esse motivo postei o código completo para ver se alguém possa dar-me uma luz na solução

 
Postado : 26/03/2018 7:35 am