Hello everyone,
I want to copy paste data from multiple workbook to single workbook. I have created sheet names Master Macro and in the sheet3 i have mentioned the names of the files(which is usually our employee names). VBA should go to the folder and fetch data from a sheet named "Rawdata" and should paste it in Master Macro workbook under sheet Rawdata. I have the below code and for some reason i keep getting a Compile error: For Without Next. I am relatively new and this code was given by one of my friend. Kindly help..
Here is the code:
Sub getLdata()
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Sheets("Rawdata").Select
Range("A2:O20000").Select
Selection.ClearContents
For i = 1 To 5
Windows("Master Macro.xlsm").Activate
Sheets("Interface").Select
qname = Sheet3.Range("A" & 1 + i).Value
ChDir "M:\Production Sheet\2021\Dec 2021\"
Workbook.Open Filename:="M:\Production Sheet\2021\Dec 2021\" & quname & ".xlsm", ReadOnly:=True
UpdateLink = False
Application.Calculation = xlCalculationManual
Sheets("Rawdata").Select
Range("A2:O3000").Select
Selection.Copy
Windows("Master Macro.xlsm").Activate
Sheets("Rawdata").Select
testval = Range("A").Value
counter = 2
While testval <> ""
counter = counter + 1
testval = Range("A" & counter).Value
Wend
Range("A" & counter).Select
Selection.PasteSpecial
Paste = xlPasteValues
Operation = xlNone
Skipblanks = False
Transpose = False
Windows(qname & ".xlsm").Activate
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
Workbook(qname & ".xlsm").Close
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
I want to copy paste data from multiple workbook to single workbook. I have created sheet names Master Macro and in the sheet3 i have mentioned the names of the files(which is usually our employee names). VBA should go to the folder and fetch data from a sheet named "Rawdata" and should paste it in Master Macro workbook under sheet Rawdata. I have the below code and for some reason i keep getting a Compile error: For Without Next. I am relatively new and this code was given by one of my friend. Kindly help..
Here is the code:
Sub getLdata()
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Sheets("Rawdata").Select
Range("A2:O20000").Select
Selection.ClearContents
For i = 1 To 5
Windows("Master Macro.xlsm").Activate
Sheets("Interface").Select
qname = Sheet3.Range("A" & 1 + i).Value
ChDir "M:\Production Sheet\2021\Dec 2021\"
Workbook.Open Filename:="M:\Production Sheet\2021\Dec 2021\" & quname & ".xlsm", ReadOnly:=True
UpdateLink = False
Application.Calculation = xlCalculationManual
Sheets("Rawdata").Select
Range("A2:O3000").Select
Selection.Copy
Windows("Master Macro.xlsm").Activate
Sheets("Rawdata").Select
testval = Range("A").Value
counter = 2
While testval <> ""
counter = counter + 1
testval = Range("A" & counter).Value
Wend
Range("A" & counter).Select
Selection.PasteSpecial
Paste = xlPasteValues
Operation = xlNone
Skipblanks = False
Transpose = False
Windows(qname & ".xlsm").Activate
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
Workbook(qname & ".xlsm").Close
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub