i am creating a new post as I could not edit the previous post
I have macro to email several sheets, but do not want to attach those sheets where A2 is blank
It would be appreciated if someone could amend my code
I have macro to email several sheets, but do not want to attach those sheets where A2 is blank
It would be appreciated if someone could amend my code
Code:
Sub Email_salesheets()
Dim Ztext As String
Dim Zsubject As String
Ztext = [bodytext] 'read in text from named cell
Zsubject = [SubjectText]
Sheets(Array("sales1", "sales2", "sales3")).Copy
With Range("A1:O150")
.Value = .Value
End With
With ActiveWorkbook
'.Windows(1).Visible = False
Application.DisplayAlerts = False
.SaveAs Environ("TMP") & "\" & ThisWorkbook.Sheets("sales1").Name & ".xlsx"
Application.DisplayAlerts = True
.Close (True)
End With
With CreateObject("Outlook.Application").CreateItem(0)
.To = Join(Application.Transpose(Sheets("Email sales").Range("AA1:AA3").Value), ";")
.Subject = Zsubject
.Body = Ztext
.Attachments.Add Environ("TMP") & "\" & ThisWorkbook.Sheets("sales1").Name & ".xlsx"
.Display
'.send
End With
End Sub