Hello,
Okay, I revisited this one and have gotten this far. The details are different but it is the same concept. Can anyone else offer assistance? I apologize for this not being indented (I don't know how to post that way.)
Sub CreateTheExcelWorkbooks()
Dim db As DAO.Database
Dim List1 As DAO.Recordset
Dim List2 As DAO.Recordset
Dim List3 As DAO.Recordset
Dim List4 As DAO.Recordset
Dim List5 As DAO.Recordset
Dim List6 As DAO.Recordset
Set db = CurrentDb()
Set List1 = CurrentDb.OpenRecordset("Select DISTINCT [super] from [Employee Snapshot]")
List1.MoveFirst
Do Until List1.EOF
'Need code to open Excel Workbook named "Supervisor.xls"
ActiveWorkbook.SaveAs "C:\Temp\" & List1.Fields("EmpName") & ".xls" 'If last character is "." remove
'Need code to copy "sheet1" and name = Left(List1.fields ("EmpName"), InStr(1, List1.fields ("EmpName"), ",", 1) - 1)
'Need code to select all records in List1 and paste into this new sheet starting at row4
Set List2 = CurrentDb.OpenRecordset("SELECT * FROM [Employee Snapshot] WHERE [super] =" & List1![EmpNo])
List2.MoveFirst
Do Until List2.EOF
'Need code to copy "sheet1" and name = Left(List2.fields ("EmpName"), InStr(1, List2.fields ("EmpName"), ",", 1) - 1)
'if worksheet name already exists, name = Left(List2.fields ("EmpName"), InStr(1, List2.fields ("EmpName"), ",", 1) - 1) & "(1)" (increment this as needed)
'Need code to select all records in List2 and paste into this new sheet starting at row4
Set List3 = CurrentDb.OpenRecordset("SELECT * FROM [Employee Snapshot] WHERE [super] =" & List2![EmpNo])
List3.MoveFirst
Do Until List3.EOF
'Need code to copy "sheet1" and name = Left(List3.fields ("EmpName"), InStr(1, List3.fields ("EmpName"), ",", 1) - 1)
'if worksheet name already exists, name = Left(List3.fields ("EmpName"), InStr(1, List3.fields ("EmpName"), ",", 1) - 1) & "(1)" (increment this as needed)
'Need code to select all records in List3 and paste into this new sheet starting at row4
Set List4 = CurrentDb.OpenRecordset("SELECT * FROM [Employee Snapshot] WHERE [super] =" & List3![EmpNo])
List4.MoveFirst
Do Until List4.EOF
'Need code to copy "sheet1" and name = Left(List4.fields ("EmpName"), InStr(1, List4.fields ("EmpName"), ",", 1) - 1)
'if worksheet name already exists, name = Left(List4.fields ("EmpName"), InStr(1, List4.fields ("EmpName"), ",", 1) - 1) & "(1)" (increment this as needed)
'Need code to select all records in List4 and paste into this new sheet starting at row4
Set List5 = CurrentDb.OpenRecordset("SELECT * FROM [Employee Snapshot] WHERE [super] =" & List4![EmpNo])
List5.MoveFirst
Do Until List5.EOF
'Need code to copy "sheet1" and name = Left(List5.fields ("EmpName"), InStr(1, List5.fields ("EmpName"), ",", 1) - 1)
'if worksheet name already exists, name = Left(List5.fields ("EmpName"), InStr(1, List5.fields ("EmpName"), ",", 1) - 1) & "(1)" (increment this as needed)
'Need code to select all records in List5 and paste into this new sheet starting at row4
Set List6 = CurrentDb.OpenRecordset("SELECT * FROM [Employee Snapshot] WHERE [super] =" & List5![EmpNo])
'Need code to copy "sheet1" and name = Left(List6.fields ("EmpName"), InStr(1, List6.fields ("EmpName"), ",", 1) - 1)
'if worksheet name already exists, name = Left(List6.fields ("EmpName"), InStr(1, List6.fields ("EmpName"), ",", 1) - 1) & "(1)" (increment this as needed)
'Need code to select all records in List6 and paste into this new sheet starting at row4
List5.MoveNext
Loop
List4.MoveNext
Loop
List3.MoveNext
Loop
List2.MoveNext
Loop
ActiveWorkbook.Sheets(1).Delete
'need code to sort worksheets in ascending order
ActiveWorkbook.Close
'Activate "Supervisor.xls"
List1.MoveNext
Loop
List1.Close
List2.Close
List3.Close
List4.Close
List5.Close
List6.Close
Set List1 = Nothing
Set List2 = Nothing
Set List3 = Nothing
Set List4 = Nothing
Set List5 = Nothing
Set List6 = Nothing
Set db = Nothing
End Sub