I have the following code that grabs data from many worksheets in my workbook and dumps it into a new worksheet named "Export_Sheet".
Since the code relies on Copy\Paste method it takes forever and I am looking to replace this with something much faster.
Any clues? I'm not looking for a resolution for this, more just a steer in the right direction, as I don't know of any faster processes myself, but am sure they exist.
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Worksheets.Add(After:=Worksheets(1)).Name = "Export_Sheet"
Dim Ws As Worksheet
For Each Ws In ThisWorkbook.Worksheets
If Ws.Name <> "Contents Page" And Ws.Name <> "Completed" And Ws.Name <> "VBA_Data" And Ws.Name <> "Front Team Project List" And Ws.Name <> "Mid Team Project List" And Ws.Name <> "Rear Team Project List" And Ws.Name <> "Acronyms" Then
LastRow = Ws.Cells(Rows.Count, 1).End(xlUp).Row
For i = 6 To LastRow
Ws.Cells(i, 9).EntireRow.Copy
Sheets("Export_Sheet").Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial xlPasteValues
Sheets("Export_Sheet").Range("j" & Rows.Count).End(xlUp).Value = Ws.Name
If Ws.Range("J1").Value = "Front Team" Then
Sheets("Export_Sheet").Range("k" & Rows.Count).End(xlUp).Offset(1).Value = "Front Team"
End If
If Ws.Range("J1").Value = "Mid Team" Then
Sheets("Export_Sheet").Range("k" & Rows.Count).End(xlUp).Offset(1).Value = "Mid Team"
End If
If Ws.Range("J1").Value = "Rear Team" Then
Sheets("Export_Sheet").Range("k" & Rows.Count).End(xlUp).Offset(1).Value = "Rear Team"
End If
Next i
End If
Next
End Sub
v = Range("A1:A999").Value
) as it is to bring 1 value into a scalar variable. The same holds true for writing data to a worksheet from VBA. – Excel Hero