Declamatory
Active Member
- Joined
- Nov 6, 2014
- Messages
- 319
Hi Folks,
I'm hoping somebody can help me. I have a workbook that has rows of transaction data with each row being a transaction. The transactions relate to a number of clients.
I currently use the following code to filter the clients by account number so all the transactions for one client are viewable then copy and paste the transactions for that client into a new worksheet. It's a bit crude because I have to update the code every time I get a new client.
This code is then repeated for every client. Then I use the following code to split out each worksheet in the workbook into a separate workbook for each client.
Is there a way I can streamline this process as it is getting to the stage where there are too many clients. I need every client to have their own workbook but I don't need every client to have their own worksheet in the Transactions workbook.
Ideally I would love these workbooks to be emailed automatically (The email address of the client is in the transaction data).
I apologise if I haven't been clear enough.
Thanks
I'm hoping somebody can help me. I have a workbook that has rows of transaction data with each row being a transaction. The transactions relate to a number of clients.
I currently use the following code to filter the clients by account number so all the transactions for one client are viewable then copy and paste the transactions for that client into a new worksheet. It's a bit crude because I have to update the code every time I get a new client.
Code:
Sheets("Transactions").Select
ActiveSheet.Cells(1, 1).Select
ActiveCell.CurrentRegion.Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Cells.Select
Cells.EntireColumn.AutoFit
LR = Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("D1:D" & LR).AutoFilter Field:=1, Criteria1:= _
"<>19720428"
Application.DisplayAlerts = False
ActiveSheet.UsedRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
ActiveSheet.AutoFilterMode = False
ActiveSheet.Name = "19720428 – Client Smith"
Sheets("Transactions").Select
This code is then repeated for every client. Then I use the following code to split out each worksheet in the workbook into a separate workbook for each client.
Code:
For Each xWs In Workbooks("Transactions.xlsm").Worksheets
If xWs.Name <> "Transactions" Then
xWs.Copy
Application.ActiveWorkbook.SaveAs FileName:=xPath & "\" & xWs.Name & ".xlsx"
Application.ActiveWorkbook.Close False
End If
Next xWs
Is there a way I can streamline this process as it is getting to the stage where there are too many clients. I need every client to have their own workbook but I don't need every client to have their own worksheet in the Transactions workbook.
Ideally I would love these workbooks to be emailed automatically (The email address of the client is in the transaction data).
I apologise if I haven't been clear enough.
Thanks