Every Monday, I run a report from Access that compiles multiple agents into one workbook with each agent having their own worksheet. Each agent is assigned a number. I need to be able to remove each worksheet and save it to it's own workbook while adding their respective agent number to the file name. I have the first part finished and was thinking I needed a separate sub function in which to call when saving.
How can I loop through each set agent number (from a list I provide within the code) and have that number save to the file path?
Each worksheet is named Agent1, Agent2, Agent3, etc.
Here is my code and agent list so far: (fyi, there can be up to 244 agents)
How can I loop through each set agent number (from a list I provide within the code) and have that number save to the file path?
Each worksheet is named Agent1, Agent2, Agent3, etc.
Here is my code and agent list so far: (fyi, there can be up to 244 agents)
Code:
Sub Sheets_to_Workbooks()
Dim wsCount As Integer
Dim x As Long
Dim LCharacters As String
LCharacters = UCase(Left(ActiveSheet.Name, 3))
wsCount = ActiveWorkbook.Worksheets.Count
For x = 1 To wsCount
Worksheets(x).Move
ActiveWorkbook.SaveAs "C:\Users\C11417\Documents\Test\" & "CC_" & LCharacters & "_CRMID_" & Format(Now, "yyyymmdd") & ".xlsx"
ActiveWorkbook.Close
Next x
End Sub
Sub Lookup_CRM_ID()
Dim CRMID As String
Agent1 = 700770
Agent2 = 700001
Agent3 = 700004
Agent4 = 700007
Agent5 = 700010
End Sub