button to open file and Import Data from one book to another

Carlit007

New Member
Joined
Sep 5, 2018
Messages
47
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
  2. MacOS
Hi I have a template workbook file that requires user to manually copy and paste data from another workbook containing 3 worksheet with numerous employer data

the desired outcome would be the information from those 3 worksheets combined together and pasted into the workbook template file worksheet named "Unit Roster"

I have been able to piece together the following code which works pretty well to combine the 3 worksheets into one sheet

VBA Code:
Sub CombineSheets()

Application.ScreenUpdating = False

Dim Sht As Worksheet
Range("B4", [B4].SpecialCells(xlLastCell)).ClearContents


For Each Sht In ActiveWorkbook.Worksheets

Sht.Activate
If Sht.Name <> "Master" And Sht.Range("B4").Value <> "" Then
Lastrow = Range("B65536").End(xlUp).Row
Range("B4", Cells(Lastrow, "M")).Copy

Sheets("Master").Select      [COLOR=rgb(147, 101, 184)] 
'Not sure If I can just skip this step and combine and copy all cells from report into  "unit roster" sheet in template workbook[/COLOR]

Range("B65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
End If
Next Sht


Application.CutCopyMode = False
Range("A1").Select


Application.ScreenUpdating = True

End Sub

what I am trying to achieve is to add a button in the template files that when clicked prompts the user to choose the file containing the employer data then runs the above macro and in the background then copies the combine data to the worksheet named "Unit Roster" in the template workbook file the columns to paste to would be on A2/I2

If there's any better way to do all of this please do share Thanks
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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