Guys,
I have this Loop which retreives a certain Range of data from each file.
This is the source: https://imgur.com/RqJL8Pt
Now i paste this this data in a masterfile by using below code.
Then all data is pasted in the masterfile like this:
https://imgur.com/8ArbE89
It works ok, UNTILL something changes in the source data.
For example, looking at column M, this value has changed during the year, so therfore it would be best to start in a new column as soon as the header changes to BFT2.
An option could be to make a yearly template with all dates and machines fixed, and paste the data in the specific destination.
I'm really strugling to describe the situation as clearly as possible. sorry if it's not...
Hope you can help me out!
I have this Loop which retreives a certain Range of data from each file.
This is the source: https://imgur.com/RqJL8Pt
Now i paste this this data in a masterfile by using below code.
Code:
Sub GetDataHalA()
'DECLARE AND SET VARIABLES
Dim wbk As Workbook
Dim Filename As String
Dim Path As String
Application.ScreenUpdating = False
Path = "W:\Operations Components\Manufactoring H\Heieinde\productie\dagrapport productie\output\Hal A\Output FY2019\"
Filename = Dir(Path & "*.xlsx")
Sheets("Outputdata").Select
ThisWorkbook.Sheets("Outputdata").Range("A1:CQ1048576").Select
Selection.ClearContents
'--------------------------------------------
'OPEN EXCEL FILES
Do While Len(Filename) > 0 'IF NEXT FILE EXISTS THEN
Set wbk = Workbooks.Open(Path & Filename)
Sheets("Weekoverzicht").Select
'Unprotect sheet
ActiveSheet.Unprotect Password:="cirules"
'Copy data from source
Range("a5:z29").SpecialCells(xlCellTypeVisible).Copy
'Paste data in Sheet 1
ThisWorkbook.Sheets("Outputdata").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'Protect sheet again
ActiveSheet.protect Password:="cirules"
'Prevents question for copy clipboard
Application.CutCopyMode = False
'wbk.Close = don't save
wbk.Close False
Filename = Dir
Loop
End Sub
Then all data is pasted in the masterfile like this:
https://imgur.com/8ArbE89
It works ok, UNTILL something changes in the source data.
For example, looking at column M, this value has changed during the year, so therfore it would be best to start in a new column as soon as the header changes to BFT2.
An option could be to make a yearly template with all dates and machines fixed, and paste the data in the specific destination.
I'm really strugling to describe the situation as clearly as possible. sorry if it's not...
Hope you can help me out!