Carlit007
New Member
- Joined
- Sep 5, 2018
- Messages
- 47
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- 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
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
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