

LastRow = Sheets("SABER").Cells(Rows.Count, Rng.Column).End(xlUp).Row ' Define LastRow as the last row of data under the Due Date header ' Set Rng as the cell where "Admin No." is found Set sRange = Sheets("SABER").Range("A1", Cells(1, LastCol)) ' Sets the search range as A1 to the last column with a header on the Run sheet LastCol = Sheets("SABER").Cells(1, Columns.Count).End(xlToLeft).Column ' Defines LastCol as the last column with a header on the Run sheet VBA macrosĬan someone help me with the following script? There is something wrong with the last call function of this.ĭim Cell As Range, sRange As Range, Rng As Range

Press Crl + S, then click the " No" button in the " The following features cannot be saved in macro-free workbook" warning dialog. Save your workbook as " Excel macro-enabled workbook".As a result, the performance is increased from 10% to 500% (aha, the macro works 5 times faster if it continuously manipulates the cells' contents). These lines, as their names suggest, turn off screen refresh and recalculating the workbook's formulas before running the macro.Īfter the code is executed, everything is turned back on. To the very of the code, before End Sub:Īpplication.Calculation = xlCalculationAutomatic.To the very beginning of the code, after all code lines that start with Dim (if there are no " Dim" lines, then add them right after the Sub line):.

Then add the following lines to get your macro to work faster (see the screenshots above): If the code of your VBA macro does not contain the following lines in the beginning:Īpplication.Calculation = xlCalculationManual Copy the VBA code (from a web-page etc.) and paste it to the right pane of the VBA editor (" Module1" window).Right-click on your workbook name in the " Project-VBAProject" pane (at the top left corner of the editor window) and select Insert -> Module from the context menu.Press Alt + F11 to open Visual Basic Editor (VBE).For this example, we are going to use a VBA macro to remove line breaks from the current worksheet.
