Macro to pick up email address within SS

Dan190984

New Member
Joined
Mar 18, 2011
Messages
26
Hi all

I am currently running the below script to send a spreadsheet to a designated email address within a ss, only issue is I have no idea what I am doing!

How do I get the script to pick up the changing email address which will always be in G45 on the active worksheet.

Sub Understood()
'Working in 97-2010
Dim wb As Workbook
Dim I As Long
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" & vbNewLine & _
"be no VBA code in the file you send. Save the" & vbNewLine & _
"file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
On Error Resume Next
For I = 1 To 3
wb.SendMail ActiveWorkbook.Sheets("Sheet1").Range("G45").Value, _
"Subject"
If Err.Number = 0 Then Exit For
Next I
On Error GoTo 0
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try something like this...

Code:
wb.SendMail ActiveWorkbook.[COLOR="Red"]ActiveSheet[/COLOR].Range("G45").Value, _
            "Subject"
 
Upvote 0
I don't think you can CC someone using the SendMail method. You can have more than one "TO:" recipients though.

Code:
wb.SendMail ActiveWorkbook.ActiveSheet.Range("[COLOR="Red"]G45:G46[/COLOR]").Value, _
            "Subject"

Otherwise if you must use CC, then you would have to send the email using another method.
Ron de Bruin's Example Code for sending mail from Excel
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,716
Members
452,939
Latest member
WCrawford

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