Notifications
Clear all

DELETAR LINHA E COPIAR PARA PLAN2

4 Posts
2 Usuários
0 Reactions
844 Visualizações
(@laeoli)
Posts: 85
Estimable Member
Topic starter
 

Boa Noite!

Srs, tenho o código abaixo, trata-se de uma exclusão de cadastro, porém além disto gostaria que esta linha fosse para a plan2 e a medida que o usuário fosse excluindo mais cadastros esta nova linha excluída, também fosse para o plan2 na próxima linha.

Dim lLinha As Long
    Dim currentFind As Range
    Dim lPosicao As String
    
    iTotalLinhas = Sheets("VOLUNTARIOS").Cells(Rows.Count, 1).End(xlUp).Row

    If IsNumeric(lblCod.Caption) = True Then
        Set currentFind = Worksheets("VOLUNTARIOS").Range("A:A").Find(lblCod.Caption, , _
            Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, _
            Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False)

        lLinha = currentFind.Row
        
        
        
   
        currentFind.EntireRow.Delete
     
       
        If lLinha <= iTotalLinhas And IsNumeric(Worksheets("VOLUNTARIOS").Cells(lLinha - 1, 1)) Then
            lsLocalizaRegistroVOLUNTARIOS (CLng(Worksheets("VOLUNTARIOS").Cells(lLinha - 1, 1)))
        End If
        
        If lLinha = 2 And iTotalLinhas > 2 Then
            lsLocalizaRegistroVOLUNTARIOS (CLng(Worksheets("VOLUNTARIOS").Cells(lLinha + 1, 1)))
        Else
            lsLimparVOLUNTARIOS
        End If
        
        
    End If

grato!

 
Postado : 14/06/2014 4:05 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa noite!!

Você consegue se basear neste raciocínio?

Sub AleVBA_12091()
Dim lr As Long
lr = Sheets("Plan2").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Plan1").Range("A" & lr).EntireRow.Cut Destination:=Sheets("Plan2").Range("A" & lr + 1)
End Sub

Não testado!!!!!!!!!!!!!!!!!!!!!!

Talvez....

currentFind.EntireRow.Cut Destination:=Sheets("Plan2").Range("A" & iTotalLinhas + 1)

Att

 
Postado : 14/06/2014 4:32 pm
(@laeoli)
Posts: 85
Estimable Member
Topic starter
 

Boa Noite, Ale!

A 1ª opção deu certo, porém na Plan1 a linha fica em branco. É necessário que a linha seja excluída. Por exemplo se excluo o cadastro 2, fica uma linha em branco entre o cadastro 1 e o 3.

 
Postado : 14/06/2014 5:19 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa noite!!

Mas eu posteie apenas um caminho, uma forma próxima.

Use a criatividade, uma forma não muito inteligente seria organizar os dados da guia "Plan1"

Att

 
Postado : 14/06/2014 5:37 pm