Hello guys.
I'm new to this forum and mainly in VBA. Started to learn it for work, in order to create automatized documents that will make life easier ^.^
I have a code that basically opens a windows explorer window where you can select multiple workbooks, and extracts data from them ( it detects the last row and column ) into a master workbook. It works great, but the problems is that it extracts only from the active sheets, not from all sheets from those workbooks. The workbooks will always have the same sheet names ( e.g Workbook 1 - Sheet 1, Sheet 2, Sheet 3, Workbook 2 - Sheet 1, Sheet 2, Sheet 3 etc ). I even tried to use Array, but with no luck.
This is my code so far.
![]()
Sub multiple_extraction() Dim filename As Variant Dim i As Integer Dim pvp_report As Workbook Set pvp_report = ActiveWorkbook Dim extragere As Worksheet Application.DisplayAlerts = False Application.ScreenUpdating = False Range("A1:D3500").Select FileNames = Application.GetOpenFilename(FileFilter:="Excel Filter (*.xlsx), *.xlsx", Title:="Open File(s)", MultiSelect:=True) For i = 1 To UBound(FileNames) ultimul_rand = pvp_report.Sheets("Extragere").Cells(Rows.Count, 1).End(xlUp).Row Workbooks.Open FileNames(i) Range("A1:D3500").Select Selection.Copy pvp_report.Activate ActiveSheet.Paste Destination:=Worksheets("Extragere").Range("A" & ultimul_rand) Workbooks.Open FileNames(i) ActiveWorkbook.Close SaveChanges:=False ActiveCell.Offset(1, 0).Activate Next i Range("A1").Select Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
Bookmarks