VBA - ActiveSheet name as Email Subject

BenGee

Board Regular
Joined
Mar 5, 2016
Messages
195
Code:
With OutMail
            .to = "name@name.co.uk"
            .CC = ""
            .BCC = ""
            .Subject = [COLOR=#ff0000]"Callback For" & Range("F1").Value[/COLOR]
            .Body = "Hi there"
            .Attachments.Add Destwb.FullName

However, the email comes up with no subject. I've also tried;

Code:
[COLOR=#ff0000]"Callback For" & Range("F1").Select[/COLOR]
Code:
[COLOR=#ff0000]"Callback For" & Range("F1")[/COLOR]

I can't see what I'm missing. Any help would be greatly appreciated :)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hello BenGee,

What error message comes up?
 
Upvote 0
Your post title says you are looking to send the active sheet name as the subject... Is there anything written in F1?


You could try to make a string before hand

Code:
Dim subjectString as String

subjectString = "Callback For " & Range("F1").Value

With OutMail
            .to = "name@name.co.uk"
            .CC = ""
            .BCC = ""
            .Subject = [COLOR=#ff0000]subjectString[/COLOR]
            .Body = "Hi there"
            .Attachments.Add Destwb.FullName

End With
 
Last edited:
Upvote 0
Thank you tygrrboi & Leith Ross for replying.

I've managed to sort now. The original code did work, it was just the cell the code was referencing contained formula not text. So have now converted this to text.
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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