'VBA to outlook avoiding highlighted cells
so I have this VBA script where I can copy data from excel to VBA. however I there are some row highlighted grey because in column "L" I put "No" and it greys out the columns B-Q for that row which I need on excel . When I copy the data to outlook I wont to avoid the grey highlighted rows.
The following is the the script that works. but I need help to code to avoid picking up the grey higlighted Items.
Please if someone can tell me where to add it that be great thank you.
Private Sub CommandButton1_Click()
Dim
lRow As Integer
Dim i As Integer
Dim eSubject As String
Dim eBody As String
Dim Sheets As Worksheet
Dim OutApp, OutMail As Object
lRow = Ce`enter code here`lls(Rows.Count, 4).End(xlUp).Row
For i = 2 To lRow
If (Cells(i, 1)) <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set sh = ThisWorkbook.Sheets("Remediation Log")
eBody = "Hello ," & vbNewLine & vbNewLine & _
"Pleased see below the list of defected file(s) that require re-testing." & vbNewLine & _
"Please help me lol ." & vbNewLine & _
"Thank you,"
On Error Resume Next
With OutMail
.To = Range("D2")
.CC = ""
.BCC = ""
.Subject = "Action Required - Re-testing defected file"
.body = eBody
.Display
Set Inspect = OutMail.GetInspector
Set pageEditor = Inspect.WordEditor
sh.Range("B:Q").Copy
pageEditor.Application.Selection.Start = Len(.body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
