Filter two tables by one attribute

Hello everyone!

I have a task to send messages. I need to take the agent number from file 1 from column A and paste the mail in the agent’s copy into the copy on send, copy the range A-B on sheet 1 on new book where only this agent number is indicated and add to mail message. Then find this agent number in file 2 and copy all the senders’ mails (they are different) from column C and add them to the letter’s address. Tell me please how can this be done? Thus, I need to deal with all the numbers from file one.
file1.xlsx (10.0 KB)
file2.xlsx (11.0 KB)

HI @yulya

If possible can you share your expected output xlsx?


As a result, a message with a file in the attachment should be sent. For example, if we took the agent number 10514, then we send a message to the addresses from file 2


, put the address from file 1 into the copy.

and attach the file xlsx
file_results for first row.xlsx (10.1 KB)
So we execute in a loop for each agent number