(VBA beginner) Combining two workbooks into one

vbabeginner1990

New Member
Joined
Apr 3, 2013
Messages
1
Hi everyone,

I am an beginner in VBA. And currently, I am working on creating a VBA code that will allow me to combine two excel files from a server into one file.

Basically, I would like to have the all the rows from the first excel file copy directly into the second excel file's last row. I have tried using relative reference from macro to do that. But because of the fact that both of those two files are in "read mode" only, I am unable to combine them for some reasons.

Could anyone show me a few line of codes of how people generally combine files?

Thank you so much in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
vbabeginner1990,

Here's one way...
Code:
Sub tgr()
    
    Dim wsDest As Worksheet
    
    Set wsDest = ActiveWorkbook.Sheets("Sheet1")
    
    On Error Resume Next
    With Workbooks.Open(Application.GetOpenFilename("Excel Files, *.xls*"))
        .Sheets(1).UsedRange.Copy wsDest.Cells(wsDest.UsedRange.Row + wsDest.UsedRange.Rows.Count, "A")
        .Close False
    End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

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