» Mail sheet(s) to one or more people using VBA in Microsoft Excel
VBA macro tip contributed by Ron de Bruin, Microsoft MVP - Excel
CATEGORY - Mail - Send and Receive in VBA
VERSION - All Microsoft Excel Versions
Every mail you want to send will use 3 columns.
- in column A - enter sheet or sheets name you want to send.
- in column B - enter E-mail address.
- in column C - the subject title appears at the top of the E-mail message.
you can send 85 different E-mails this way (85*3 = 255 columns).
Sub Mail_sheets()
Dim MyArr As Variant
Dim last As Long
Dim shname As Long
Dim a As Integer
Dim Arr() As String
Dim N As Integer
Dim strdate As String
For a = 1 To 253 Step 3
If ThisWorkbook.Sheets("mail").Cells(1, a).Value = "" Then Exit Sub
Application.ScreenUpdating = False
last = ThisWorkbook.Sheets("mail").Cells(Rows.Count, a).End(xlUp).Row
N = 0
For shname = 1 To last
N = N + 1
ReDim Preserve Arr(1 To N)
Arr(N) = ThisWorkbook.Sheets("mail").Cells(shname, a).Value
Next shname
ThisWorkbook.Worksheets(Arr).Copy
strdate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
ActiveWorkbook.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
With ThisWorkbook.Sheets("mail")
MyArr = .Range(.Cells(1, a + 1), .Cells(Rows.Count, a + 1).End(xlUp))
End With
ActiveWorkbook.SendMail MyArr, ThisWorkbook.Sheets("mail").Cells(1, a + 2).Value
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
Application.ScreenUpdating = True
Next a
End Sub
Book Store:
Recommended Books:
- The Ernst & Young Business Plan Guide
- How to Use Financial Statements: A Guide to Understanding the Numbers
- Personal Finance for Dummies
- Treason: Liberal Treachery from the Cold War to the War on Terrorism
- Successful Business Planning in 30 Days: A Step-By-Step Guide for Writing a Business Plan and Starting Your Own Business
Mail_sheets macro doesn't work
SamBoy12
I tried running your "Mail_sheets" macro without success.
The concept looks great and would save me heaps of time but when I run it, it stops at Line 10 with the following message.
Run-time error '9':
Subscript out of range.
Can you please help ?
Mail_sheets macro doesn't work
SamBoy12
it works fine very fine
julio cesar alvarez
I follow your instructions to running your "Mail_sheets" macro and it works.
Thanks
Brings up netscape
Ash
Excel brings up netscape on my pc !
The other person who got this error:
Can you please help ?
Mail_sheets macro doesn't work
- all this means is that your sheet name in column A is invalid !
This site is not moderated & no body will hwlp you
you may contatct to ron for help
you may contatct to ron for help


The concept looks great and would save me heaps of time but when I run it, it stops at Line 10 with the following message.
Run-time error '9':
Subscript out of range.
Can you please help ?