Optimization in VBA code?

Posted on

Question :

I have two spreadsheets, both have the same header, with 77 columns. For test I put 4 rows with data filled in one of the tables. In the table with the data filled in, I have the button with the macro, to copy this data to the worksheet that has only the header, however, so that this macro finalizes the copy to the other worksheet takes approximately 30 minutes. Since the purpose is to optimize a manual process, in which there will be much more than 4 lines of data filled, the macro will become unfeasible in this way. Is there a way to optimize the code and reduce this time? The code is as follows:

Sub Percorre()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.DisplayAlerts = False

Dim contador, col As Integer
Dim valor, PastaAtual, NomeDoArquivo, NomeCompletoDoArquivo As String
Dim Busca As Range
Dim RangeFrom As Range
Dim RangeTo As Range
Dim Busca_col As Integer
Dim WorkBookNovo As Workbook

contador = 0
col = 1

PastaAtual = Application.ActiveWorkbook.Path
NomeDoArquivo = "teste.xlsx"
NomeCompletoDoArquivo = PastaAtual + "" + NomeDoArquivo

Answer :

Leave a Reply

Your email address will not be published. Required fields are marked *