Forum

Filter data by name...
 
Notifications
Clear all

Filter data by name and email

2 Posts
2 Users
0 Reactions
90 Views
(@mikerodwell)
Posts: 1
New Member
Topic starter
 

Hi,

I have made a script to email multiple users however, I am struggling filtering the data and pasting that data into an email for that particular user.

Sheet 1 has "Name", "Email" and "Yes/No"

Sheet 2 will have project name, whos accountable "name"

I want the program to filter the data and tally up how many actions that user has then email it to them using a lookup from sheet 1.

Code below works perfectly for email multiple users, but doesn't contain the filtered data.

Any help/advise?

Sub Test1()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "C").Value) = "yes" Then

            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "Reminder"
                .Body = "Dear " & Cells(cell.Row, "A").Value _
                      & vbNewLine & vbNewLine & _
                        "Please contact us to discuss bringing " & _
                        "your actions up to date"
                '.Attachments.Add ("C:test.txt")
                .Send  'Or use Display
            End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

 
Posted : 14/11/2019 1:39 pm
(@catalinb)
Posts: 1937
Member Admin
 

I can see you are already using special cells, maybe you want to use instead: .SpecialCells(xlCellTypeVisible)

Or, you can just add a new condition, to check the row height:

If Cells(cell.Row, "C").RowHeight>0 then...

 
Posted : 14/11/2019 2:53 pm
Share: