Testa essa adaptação
Sub Transferir()
Dim WRel As Worksheet
Dim WEst As Worksheet
Dim WB As Workbook
Dim Cod As String
Dim Orc As String
Set WRel = Sheets("REL_ORC_NUM")
Set WEst = Sheets("TAB_ESTOQUE")
Set WB = Workbooks("Exemplo_Ajuda")
Orc = WRel.Range("C6").Value
WEst.Select
WEst.Range("G3").Select
WRel.Select
WRel.Range("B9").Select
Application.ScreenUpdating = False
Inicio:
Cod = ActiveCell.Value & Orc & ActiveCell.Offset(0, 3).Value
Do While ActiveCell <> ""
If ActiveCell.Value & ActiveCell.Offset(0, 2).Value & ActiveCell.Offset(0, 3).Value = Cod Then
ActiveCell.Offset(0, 5).Select
Selection.Copy
WEst.Select
Do While ActiveCell <> ""
If ActiveCell.Value & ActiveCell.Offset(0, 4).Value & ActiveCell.Offset(0, 5).Value = Cod Then
If ActiveCell.Offset(0, 7).Value = "" Then
ActiveCell.Offset(0, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
WEst.Range("G3").Select
WRel.Select
ActiveCell.Offset(1, -5).Select
GoTo Inicio
Else
ActiveCell.Offset(1, 0).Select
End If
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
WEst.Select
WEst.Range("G3").Select
WRel.Select
Application.CutCopyMode = False
If ActiveCell <> "" Then
ActiveCell.Offset(1, -5).Select
GoTo Inicio
Else
GoTo Sair
End If
Sair:
WEst.Select
WEst.Range("G3").Select
WRel.Select
WRel.Range("B9").Select
MsgBox "Atualização Concluida com Sucesso", vbOKOnly, "Atenção"
Application.ScreenUpdating = True
WB.Save
End Sub
Pelos testes ta ok
Marcelo Prudencio
Microsoft Excel Brasil no Facebook
"Começar já é a metade do caminho."
Autor Desconhecido
Simplifica que simples fica.
Nicole Tomazella.
"O Simples é Sempre Melhor Que o Complicado"
Jorge Paulo Lemann.
Postado : 22/09/2015 12:45 pm