-2

Is there a way to pull data from different excel files into a single excel file?

For example, pulling data from excel file (1) and excel file (2) into a single new excel file(1_2)

Community
  • 1
  • 1

2 Answers2

0

If you mean by 'pulling data from file 1 and 2 to file 3' that you copy data from different workbooks to a new one i suggest you take a look at

this answer https://stackoverflow.com/a/19352099/5902728

For answer completeness a snippet of the linked answer (by @David Zemens):

Sub foo()
Dim x As Workbook
Dim y As Workbook

'## Open both workbooks first:
Set x = Workbooks.Open(" path to copying book ")
Set y = Workbooks.Open(" path to destination book ")

'Now, copy what you want from x:
x.Sheets("name of copying sheet").Range("A1").Copy

'Now, paste to y worksheet:
y.Sheets("sheetname").Range("A1").PasteSpecial

'Close x:
x.Close

End Sub

for selecting the complete range of a workbook:

With x.Sheets("name of copying sheet").UsedRange
    'Now, paste to y worksheet:
    y.Sheets("sheet name").Range("A1").Resize( _
        .Rows.Count, .Columns.Count) = .Value
End With

I'm not quite sure if this is what you meant so please update your answer with more details.

Also make sure to search SO or Google.

If you want to know anything else let me know.

Community
  • 1
  • 1
VetusSchola
  • 41
  • 1
  • 5
0

Of course there is a way to do this. Actually, there are MANY ways to do this. See the VBA code posted above. Also, consider using this AddIn from the link below.

https://www.rondebruin.nl/win/addins/rdbmerge.htm

enter image description here

Using that AddIn, you can easily merge data from multiple Excel files in a folder, files that contain certain characters in the file name, specific worksheet names, ranges of certain sheets, and so on and so forth.

ASH
  • 20,759
  • 19
  • 87
  • 200