Bom dia galera,
Criei um código aos trancos e barrancos,
Quando rodo ela por partes ele funciona tranquilo.
Quando rodo ele todo o Excel fica 'travado' e o código não termina.
Alguém me ajuda em alguma parte que fica mais rápido.
Private Sub ConfBase()
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
On Error Resume Next
' Base Anterior vs. Base Atual
Dim a, b, c As Long
Dim MesAnterior, MesAtual As Date
MesAnterior = CDate("31/10/2019")
MesAtual = CDate("30/11/2019")
c = Planilha3.Range("B1048576").End(xlUp).Row
    For a = 2 To 100000
            
            If Planilha2.Cells(a, 1) = "" Then Exit For
                If Planilha2.Cells(a, 2) = MesAnterior And Planilha2.Cells(a, 10) <> "" Then
                    
                b = 2
                Do While b <= Planilha2.Range("A1048576").End(xlUp).Row
                    
                    If Planilha2.Cells(b, 2) = MesAtual Then
                        If Planilha2.Cells(b, 10) = Planilha2.Cells(a, 10) Then
                            If Planilha2.Cells(b, 12) <> Planilha2.Cells(a, 12) Or Planilha2.Cells(b, 17) <> Planilha2.Cells(a, 17) Then
                            
                            Planilha3.Cells(c, 2) = Planilha2.Cells(a, 10) 'id Posição
                            Planilha3.Cells(c, 3) = MesAnterior            'Data Base Anterior
                            Planilha3.Cells(c, 4) = Planilha2.Cells(a, 12) 'Cargo
                            Planilha3.Cells(c, 5) = Planilha2.Cells(a, 17) 'Diretoria
                            
                            Planilha3.Cells(c, 6) = MesAtual               'Data Base Anterior
                            Planilha3.Cells(c, 7) = Planilha2.Cells(b, 12) 'Cargo
                            Planilha3.Cells(c, 8) = Planilha2.Cells(b, 17) 'Diretoria
                            
                            c = c + 1
                            
                            Exit Do
                            
                            Else
                            
                            Exit Do
                            
                            End If
                                               
                        Else
                        
                        b = b + 1
                        
                        End If
                                                
                    Else
                    
                    b = b + 1
                        
                    End If
                Loop
                End If
    Next a
    
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
                                                                                                	                                                
	                                         
                    
                    	
                            Postado : 26/12/2019 9:24 am