Combining rows from multiple workbooks to one workbook

gokan

New Member
Joined
Jun 19, 2019
Messages
1
Hello everyone,

I'm newbie at VBA but still learning :)

I need a macro that combines every row from a worksheet to another one.

Sample Files: https://www.dropbox.com/sh/17ukkp4dgnudle7/AAAF7GUewNXekZdkVvHh2xVFa?dl=0

In this files, you see 4 sample files and 1 combined file.. every file structure is dynamic, so i think every file run rule like "copy all rows that's not empty." and they've grouping too.
I made a macro that inserting columns G,M,Z columns.

Code:
Sub LoopThroughFiles()    Dim xFd As FileDialog
    Dim xFdItem As Variant
    Dim xFileName As String
    Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
    If xFd.Show = -1 Then
        xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
        xFileName = Dir(xFdItem & "*.xls*")
        Do While xFileName <> ""
            With Workbooks.Open(xFdItem & xFileName)
            
            'Açılacak olan kolonları yaz.
            Range("G1").EntireColumn.Insert
            Range("M1").EntireColumn.Insert
            Range("Z1").EntireColumn.Insert
            
            'Açık olan her workbook için kaydedip çıkar.
            For Each w In Application.Workbooks
            w.Save
            Next w
            ActiveWorkbook.Close SaveChanges:=True




            End With
            xFileName = Dir
        Loop
    End If
End Sub

we can integrate this too but this will be first step.

1) Insert empty columns G,M,Z. (In these we're selecting folder, it applies every workbook in this folder)
2) Copy rows with grouping for file 1.xlsx (Starting with A3)
3) Create a workbook, paste. (for example Final.xslx)
4) Copy rows with grouping for file 2.xlsx (Starting with A3)
5) In the final.xslx search empty column in A column (after 1.xslx) and paste it with grouping.

it goes like this.

I'm very appreciated
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top