Bomino
Member
Hi experts,
I would like someone to please look at the following code and make it execute a little faster. Thank you.
I would like someone to please look at the following code and make it execute a little faster. Thank you.
Code:
Sub Feeder()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Main.Range("xferdata")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = DATA
Lr = DATA.Cells(Rows.Count, 1).End(xlUp).Row
'With the information from the LastRow function we can create a
'destination cell
Set DestRange = DestSheet.Range("B" & Lr + 1)
'We make DestRange the same size as SourceRange and use the Value
'property to give DestRange the same values
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
Dim lastRow As Long, counter As Long
Dim cell As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Data")
lastRow = ws.Range("B" & ws.Rows.Count).End(xlUp).Row
counter = 1
For Each cell In ws.Range("A6:A" & lastRow)
cell.Value = counter
counter = counter + 1
Next cell
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub