Discussion Locked

Splitting Excel Sheets

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I regularly get an Excel Spreadsheet from our payroll department that contains separate sheet for each of the people in my team (30) I need to then distribute the indervidual sheets to each person. Does any one know of a way to automatically split out each "sheet" and put it in to it own file and forward to the indervidual?

5 replies

by parier

=concatenate(sheet1!A1)

This will copy wherever you put it to wherever you reference it from, for example, if A1 on sheet was the first name, then enter this on sheet2, then only that person would be on sheet 2, and do so for each person, and save this as a template and next time you have data, you can just paste it onto sheet 1 and all other pages should link from that. if you need more info, send me something that you are workng with and I will show you and return the file.

Hope thishelps
Eric

by rdenyer

Still need to auotmate answer below allowed me to simply run a macro each month.

by peyison

To do this manually, you'd right click on the tab of a sheet, select "Move or Copy...", and in the "To Book" dropdown, select (new book).

The following macro code will automate the process of copying a sheet to a new workbook, saving it, and emailing it.

Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:="C:\My Documents\JohnDoe.xls"
ActiveWorkbook.SendMail "JohnDoe@yahoo.com", "Payroll Info"
ActiveWorkbook.Close

You could put this in a loop to do this for all of the sheets in your workbook. If the sheet name was the employee's email address, you could loop through all sheets very easily with a loop like:

Sub PRLoop()
Dim oSheet As Worksheet
Dim sName As String

For Each oSheet In ActiveWorkbook.Sheets
sName = oSheet.Name
oSheet.Copy
ActiveWorkbook.SaveAs Filename:="C:\My Documents\" & sName & ".xls"
ActiveWorkbook.SendMail sName & "@YourCo.com", "Payroll Info"
ActiveWorkbook.Close
Next

End Sub

Hope this helps.

This discussion is closed to new replies.