Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi good evening, hope you can help me please? i have the code below which works great when i click the command button, it copies the data from sheet 'Raised' and pastes it into the body of the email. But i need it to cut it from sheet 'Raised' and move it into sheet 'Additional Job' can you help me please?
VBA Code:
Private Sub CommandButton3_Click()
Const PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003"
Dim aOutlook As Object
Dim aEmail As Object
Dim ulFlags As Integer
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Dim rngDataToEmail As Range
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
ulFlags = ulFlags Or &H1 ' SECFLAG_ENCRYPTED
aEmail.PropertyAccessor.SetProperty PR_SECURITY_FLAGS, (ulFlags)
With Sheets("Raised")
Set rngDataToEmail = .Range("B1:Q" & .Range("B" & Rows.Count).End(xlUp).Row)
End With
Sheets("Raised").Select
Columns("A:R").Select
With Selection
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
aEmail.HTMLBody = "<html><body><p>Hi</p>" & _
"<table border=""1"", cellpadding=""10"", style=background:""0xFFFFFF"" >" & _
"<td>" & Me.ComboBox2.Value & "</td>" & _
"<td>" & RangetoHTML(rngDataToEmail) & "</td>" & _
"</table>" & _
"<br><br><br>" & _
"<td>Any issues let your FTL know ASAP</td>" & _
"<td><p>Many Thanks</td>" & _
"<td><p>Complex Team</td>" & _
"<td></body></html>"
aEmail.Recipients.Add (UserForm8.TextBox21.Value)
aEmail.CC = ""
aEmail.BCC = ""
aEmail.Subject = (UserForm1.TextBox8.Value)
aEmail.Display
Unload Me
End Sub