Merging workbooks while editing them

wirkkarn

New Member
Joined
Oct 24, 2021
Messages
1
Office Version
  1. 365
Hello,
I have many files that i want to merge into one workbook, the problem is that the files all have 3 worksheets and i would like to edit them before merging them into one.

I have used this vba code to copy every workbook into one:
VBA Code:
Sub MergeWorkbooks()

Dim FolderPath As String
Dim File As String
Dim i As Long

FolderPath = "C:\x"

File = Dir(FolderPath)

Do While File <> ""

    Workbooks.Open FolderPath & File
        ActiveWorkbook.Worksheets().Copy _
            after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
            Workbooks(File).Close
            
    File = Dir()

Loop

End Sub

I Have also used this macro to do the editing to the workbooks I want to merge:

Code:
Sub Börsdata()
'
' Börsdata Makro
'

'
    Range("B13:C28").Select
    Selection.Cut
    Sheets("R12").Select
    Range("N1").Select
    ActiveSheet.Paste
    Columns("N:N").EntireColumn.AutoFit
    Columns("O:O").EntireColumn.AutoFit
    Sheets("Info").Select
    ActiveWindow.SelectedSheets.Delete
    Sheets("Quarter").Select
    ActiveWindow.SelectedSheets.Delete
End Sub

Is there a way to combine these so that the vba would handle the copying and editing the files to one workbook?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,013
Messages
6,122,694
Members
449,092
Latest member
snoom82

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