Pergunta

Eu estou tentando adicionar um arquivo de folha para a minha pasta de trabalho onde fechadas são coletados.Eu gostaria que a linha de um determinado bilhete de ser cortado de uma folha rotulada de "Bilhetes" e colado em uma folha identificada 'Arquivo' uma vez que o seu estatuto foi alterado de aberto para fechado.Eu gostaria que esta para acontecer usando uma private sub de modo que acontece na alteração de célula.O Estado é encontrado na coluna 4.

Se for possível im, supondo que vai ser possível fazer o caminho inverso também.Assim, se um bilhete for reaberto novamente e seu status é alterado no 'Arquivo' folha será cortar e colar de volta para o 'Bilhetes' folha.

Esse é o código que temos até agora.Podemos parecem fazê-lo funcionar.Qualquer ajuda seria muito apreciada.Obrigado

Private Sub Worksheet_Change (ByVal Target As Range) 

If Target.Column = 4 Then 
If Target.Value = "Closed" Then
   R = Target.Row 
   Rows(R).Cut 
   Worksheets("Archive").Select
     With ActiveSheet
      lastrow = .Cells(.Rows.Count,"B").End(xlUp).Row
     End With
   Cells(lastrow,1).Select
   Selection.Paste
End If
End If 
End sub 
Foi útil?

Solução

Basta fazer pequenas alterações para o código atual:

If Target.Column = 4 Then
If Target.Value = "Closed" Then
   R = Target.Row
   Rows(R).Cut
   Worksheets("sheet3").Select
     With ActiveSheet
      lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
      .Cells(lastrow, 1).Select
      .Paste
     End With
End If
End If
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top