I'm relatively new to VBA and I'm trying to move data from one workbook to another. Specifically I'm trying to move row elements from the first workbook which can be selected using the code I have and move it to Book1 in a specific way. My current goal is to move elements from the 3rd row of the selected file and copy each cell of that row 358 times down column C and then move to the next cell in the row and copy it 358 times as well. The row contains 62 elements which each have to be copied 358 times down a column. The row starts from column 2.
The code I'm using is :
Dim SelectedBook As Workbook
Dim lastRow As String
Dim i As Long
Dim j As Long
Dim n As Long
i = 1
j = 1
n = 2
FileToOpen = Application.GetOpenFilename(Filefilter:="Excel Files (*.xls*), *.xls*", Title:="Select FIles")
Do While n <= 62
Do While j <= 358
Set OpenBook = Application.Workbooks.Open(FileToOpen)
Cells(3, n).Select
Selection.Copy
Windows("Book1").Activate
lastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row + 1
Range("C" & lastRow).Select
Selection.PasteSpecial
ActiveSheet.Paste
j = j + 1
Loop
j = 1
n = n + 1
Loop
End Sub
The copying happens but because it is happening cell by cell its taking forever due to there being so many cells and the repetition as well. Is there anyway to speed this up in such a way that it can run faster? Any help would be appreciated, thanks in advance!