hello
i need help to make this code so faster recently is so slow i appreciate if anybody help
Code
Sub Macro1()
Dim wsInput As Worksheet, wsOutput As Worksheet
Dim lngStartRow As Long
Dim lngLastRow As Long
Dim lngMyRow As Long
Dim lngPasteRow As Long
Dim lngLoop As Long
Dim xlnCalcMethod As XlCalculation
With Application
xlnCalcMethod = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
Set wsInput = ThisWorkbook.Sheets("Sheet1") 'Name of input (source) data sheet. Change to suit.
Set wsOutput = ThisWorkbook.Sheets("Sheet2") 'Name of output (destination) data sheet. Change to suit.
lngStartRow = 3 'Starting row number for the data for both sheets. Change to suit.
lngLastRow = wsInput.Range("A:M").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
lngPasteRow = lngStartRow
For lngMyRow = lngStartRow To lngLastRow
For lngLoop = 1 To wsInput.Range("L" & lngMyRow)
wsInput.Range("A" & lngMyRow & ":M" & lngMyRow).Copy Destination:=wsOutput.Range("B" & lngPasteRow)
wsOutput.Range("A" & lngPasteRow).Value2 = lngLoop
wsOutput.Range("N" & lngPasteRow).Value2 = Evaluate("G" & lngPasteRow) + lngLoop
lngPasteRow = lngPasteRow + 1
Next lngLoop
lngPasteRow = lngPasteRow + 2
Next lngMyRow
With Application
.Calculation = xlnCalcMethod
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Display More