MartineM
02-20-2021, 06:40 AM
Hi All
I am a newbie at VBA coding and having trouble getting my head around it. I have looked at other posts but not sure which one suits what I need, so I apologize if this question has already been answered previously.
I did write a very small bit of code that was working but it wasn't doing what I wanted it to do, so I tried adding in more information, still works and still doesn't do what I need it to do. I guess I am missing a lot of information.
I am wondering if anyone may be able to look at my code and see what is missing and guide me in the right direction. I have used little emojis to show which parts are working.
Thank you so much
What I want my code to do
Select the email address in D16 on sheet 1 (“PO Home”) :yes
Select the worksheet (“PO Home”) :yes
Hide data in range (K:P) :yes
Copy sheet :yes
Convert the sheet to PDF format :crying:
Send as an attachment:crying:
Have a Subject title – “Purchase Order” (Located in “E3”):crying:
Have a body text –:banghead:
Dear __Use the name of the person in Cell (“D11)
“Please supply the items on the attached Purchase Order
Thank you Sign with “Andy Munday JLM Homes”
Send the email
to address in D16,:yes
confirm the correct address,:crying:
delivery / read receipt:crying:
Do not save the file:yes
Sub Send_Worksheet()
Dim semail_Recipients As String
range("D16").Select
Dim Title As String
range("E3").Select
Dim PDFfile As String
ActiveSheet.ExportAsFixedFormat xlTypePDF 'convert to PDF format
Dim Wb As Workbook
Sheets("PO Home").Select
ThisWorkbook.Worksheets("PO Home").Copy 'copy sheet 1 before sending
Worksheets("PO Home").range("K:P").EntireColumn.Hidden = True
With ActiveWorkbook 'send email
.SendMail range("D16")
.Subject = Title
.Body = "Hello, please supply items as per attached Purchase Order" & "Thank you" & "Myname"
.Close SaveChanges:=False 'dont save changes
End With
End Sub
I am a newbie at VBA coding and having trouble getting my head around it. I have looked at other posts but not sure which one suits what I need, so I apologize if this question has already been answered previously.
I did write a very small bit of code that was working but it wasn't doing what I wanted it to do, so I tried adding in more information, still works and still doesn't do what I need it to do. I guess I am missing a lot of information.
I am wondering if anyone may be able to look at my code and see what is missing and guide me in the right direction. I have used little emojis to show which parts are working.
Thank you so much
What I want my code to do
Select the email address in D16 on sheet 1 (“PO Home”) :yes
Select the worksheet (“PO Home”) :yes
Hide data in range (K:P) :yes
Copy sheet :yes
Convert the sheet to PDF format :crying:
Send as an attachment:crying:
Have a Subject title – “Purchase Order” (Located in “E3”):crying:
Have a body text –:banghead:
Dear __Use the name of the person in Cell (“D11)
“Please supply the items on the attached Purchase Order
Thank you Sign with “Andy Munday JLM Homes”
Send the email
to address in D16,:yes
confirm the correct address,:crying:
delivery / read receipt:crying:
Do not save the file:yes
Sub Send_Worksheet()
Dim semail_Recipients As String
range("D16").Select
Dim Title As String
range("E3").Select
Dim PDFfile As String
ActiveSheet.ExportAsFixedFormat xlTypePDF 'convert to PDF format
Dim Wb As Workbook
Sheets("PO Home").Select
ThisWorkbook.Worksheets("PO Home").Copy 'copy sheet 1 before sending
Worksheets("PO Home").range("K:P").EntireColumn.Hidden = True
With ActiveWorkbook 'send email
.SendMail range("D16")
.Subject = Title
.Body = "Hello, please supply items as per attached Purchase Order" & "Thank you" & "Myname"
.Close SaveChanges:=False 'dont save changes
End With
End Sub