January1991
New Member
- Joined
- Nov 5, 2024
- Messages
- 5
- Office Version
- 365
Hi,
I am trying to send out trade recaps to our clients, but we have many different clients, but when I run the macro it groups all clients together and adds them to one email. I would like to be able to differentiate between clients.
As you can see there are multiple different accounts, but all client accounts start with AGR PH9, I would like to split them up into individual client emails for example AGR PH9AGA and PH9AVOT or AGR PH9TRVPG.
Here is the code I had originally that worked until we changed the account names in our internal systems so that all client accounts start with AGR PH9....
'Construct individual recap per client
Do
Bool_Option = False
Worksheets("Recap").Select
Range("A1:M1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Worksheets("Original Data").Select
Range("A1:M1").Select
Selection.Copy
Worksheets("Recap").Select
Range("A1:M1").Select
ActiveSheet.Paste
Worksheets("Original Data").Select
Range("J2").Select
If Range("J3").Value = "" Then
Else: Selection.End(xlDown).Select
End If
' If IsError(Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)) Then
' client = Selection.Text
' Else:
client = Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)
' End If
Do
NbClientOrders = NbClientOrders + 1
Selection.Offset(-1, 0).Select
If Selection.Text = "Account" Then
Exit Do
End If
' If IsError(Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)) = True Then
' client2 = Selection.Text
' Else:
client2 = Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)
' End If
Loop Until client2 <> client
Range("A1").Select
Selection.Offset(NumberOfTrades - NbClientOrders + 1, 0).Select
Range(Selection, Selection.Offset(NbClientOrders - 1, 12)).Select
Set rng = Selection
I am trying to send out trade recaps to our clients, but we have many different clients, but when I run the macro it groups all clients together and adds them to one email. I would like to be able to differentiate between clients.
As you can see there are multiple different accounts, but all client accounts start with AGR PH9, I would like to split them up into individual client emails for example AGR PH9AGA and PH9AVOT or AGR PH9TRVPG.
Here is the code I had originally that worked until we changed the account names in our internal systems so that all client accounts start with AGR PH9....
'Construct individual recap per client
Do
Bool_Option = False
Worksheets("Recap").Select
Range("A1:M1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Worksheets("Original Data").Select
Range("A1:M1").Select
Selection.Copy
Worksheets("Recap").Select
Range("A1:M1").Select
ActiveSheet.Paste
Worksheets("Original Data").Select
Range("J2").Select
If Range("J3").Value = "" Then
Else: Selection.End(xlDown).Select
End If
' If IsError(Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)) Then
' client = Selection.Text
' Else:
client = Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)
' End If
Do
NbClientOrders = NbClientOrders + 1
Selection.Offset(-1, 0).Select
If Selection.Text = "Account" Then
Exit Do
End If
' If IsError(Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)) = True Then
' client2 = Selection.Text
' Else:
client2 = Left(Right(Selection.Text, Len(Selection.Text) - WorksheetFunction.Find(" ", Selection)), WorksheetFunction.Find(" ", Selection) - 1)
' End If
Loop Until client2 <> client
Range("A1").Select
Selection.Offset(NumberOfTrades - NbClientOrders + 1, 0).Select
Range(Selection, Selection.Offset(NbClientOrders - 1, 12)).Select
Set rng = Selection