Macro to send via email specific sheet tabs to specific people?

pgsullivan

New Member
Joined
Oct 7, 2011
Messages
19
Hi folks

need a bit of expert help please! :)

i have a big excel workbook with maybe 30 sheet tabs, maybe 5 of them are my various calculations, lookups etc and after a certain tab they are all the outputs and each of these sheet tabs are titled with some letters to signify the manager responsible.

The help i am looking for is to see if it is possible via macro code to lookup a sheet tab after a certain point eg after one called 'summary' then email just the sheet tab (not the whole workbook) to a specified email.

I have other macros run which hard code all formula so no links remain.

I am not sure i am being too clear, so i will try to give an example.

I have a sheet tab called 'Look Ups' which in column A has a 3 digit team code and then in column B is the actual name of the team leader. In column C i was hoping to add in an email address.

i would like a macro to cycle through the lookup list in column A, use the team code it finds there to then select the same named sheet tab and then email just that sheet tab to the actual email address of the team leader it matches to in column c of my lookup up list, then keep doing this until it reaches the end of the team codes.

Hope this makes sense in the help i am asking for!!

thanks

Paul
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi Paul,

Ron de bruin has examples for many different scenarios of using Excel to send workbooks and worksheets.

Mail from Excel example pages

If you need any help adapting one of these examples to your situation, just post the code you are trying and any problems you are having.

Hello, I wunderkind any one can help, I'm using the code found on the above website but looking for it to be tweaked slightly, I need the file name to be the same as say A1 and the subject to be the same as A2 the code I have at the moment is:

So far it opens outlook withe email address subject and body text by it dosent attach the file
Any help would be greatly appreciated and thank you
Sub Upload()

Dim wb1 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set wb1 = ActiveWorkbook

'Make a copy of the file/open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Set Up"
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.to = "Test@test.Co.uk
.cc = ""
.BCC = ""
.Subject = "This is Only A Test"
.Body = "Hi There"
.Attachment.Add TempFilePath & TempFileName & FileExtStr
.Display
End With
On Error GoTo 0

'Delete the File
Kill TempFilePath & TempFileName & FileExtStr

Set OutMail = Nothing
Set OutApp = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
 
Upvote 0
Rather than coding an email address here:
With OutMail
.to = "Test@test.Co.uk

I would like to address a specific cell (e.g. C8).

I've tried:
With OutMail
.to = Range("C8").Value

but get an error.

Any input will be appreciated!
 
Upvote 0
Rather than coding an email address here:
With OutMail
.to = "Test@test.Co.uk

I would like to address a specific cell (e.g. C8).

I've tried:
With OutMail
.to = Range("C8").Value

but get an error.

Any input will be appreciated!

Does the code you have work correctly when a constant value is used?
Code:
With OutMail
 .to = "Test@test.Co.uk"
End With

If so, it should also work by referencing a cell with that value.
Two things to check...
The value in the cell should not have quote marks around it (eg just: Test@test.Co.uk)
That snippet doesn't include a reference to the worksheet, so Excel will use the default of the ActiveSheet.

You could make that explicit with...

Code:
With OutMail
  .To = Sheets("MyContactList").Range("C8").Value
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,304
Members
448,564
Latest member
ED38

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