01.03.2022, 20:45
Verzichte immer auf 'Activate' und 'Select' in VBA.
Verwende With...End With statt Set x=
Konsolidiere sheets(1) in Dateien "G:\OF\Jahr_2018.xlsx", "G:\OF\Jahr_2019.xlsx" und "G:\OF\Jahr_2020.xlsx"
Verwende With...End With statt Set x=
Konsolidiere sheets(1) in Dateien "G:\OF\Jahr_2018.xlsx", "G:\OF\Jahr_2019.xlsx" und "G:\OF\Jahr_2020.xlsx"
Code:
Sub M_snb()
c00="G:\OF\"
sn=split("Jahr_2018 Jahr_2019 Jahr_2020")
for j=0 to ubound(sn)
with getobject(c00 & sn(j) & ".xlsx")
sp=.sheets(1).usedrange
.close 0
end with
thisworkbook.sheets(1).cells(rows.count,1).end(xlup).offset(1).resize(ubound(sp),ubound(sp,2))=sp
next
End Sub