Automatically send emails to multiple recipients identified by IF formula

asiuol84

New Member
Joined
Oct 19, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have highlighted the bit in green where I am having issue. I want the email to be sent to multiple recipients that are found from a table using an IF statement. I know that if I just reference the cell, it won't work because it's a formula - but don't know how to make it work! Very New to this, and learning as I go.

This is the formula in the cell that I want to reference and send the email to: Cell A9 Sheet1 =TEXTJOIN(";"|TRUE||IF(StaffDetails!$A$2:$A$10000="Manager"|StaffDetails!$C2:$C1000|"")) (The email addresses of managers within the staff list)



I have this set up as part of a larger list of code:

Sub SendColHYesMail(rw As Range)
Const NL2 As String = vbNewLine & vbNewLine
Dim mMailBody As String

mMailBody = "Hi " & NL2 & _
rw.Columns("B") & " has sent an expert to approve" & NL2 & _
"See Row " & rw.Columns("A").Value & NL2 & _
"Name: " & rw.Columns("D").Value & (" ") & Range("E3") & NL2 & _
"Platform: " & rw.Columns("F").Value & NL2 & _
("Handle: ") & rw.Columns("G").Value & NL2 & _
"Thank you"

SendAMail recip:="multiple email addresses found by IF", CC:="", BCC:="", _
subject:=rw.Columns("B") & " has sent an expert to approve", _
bodyText:=mMailBody

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,428
Messages
6,124,832
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top