![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#19
|
|||
|
|||
|
Hi,
Not tested but check this. Copy both codes. to Code module. You will need to modify the email module to your data. Could not test. I'm using a "Mac" ''' Added"""" the filer is set to look at column 8 or "H". Code:
Sub Filter_NonBank()
Application.ScreenUpdating = False
Dim Myval As Integer
Dim lrow As Long
lrow = Sheets("Bin inventory").Range("H65536").End(xlUp).Row
Selection.AutoFilter
Sheets("Bin inventory").Range("A1:k1").Select
Selection.AutoFilter
With Selection
.AutoFilter Field:=8, Criteria1:="<>" '' this set the filtered data for the value
End With
With Worksheets("Bin inventory").AutoFilter.Range
Set VisRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
'' make sure you have more than 1 row ''
Myval = .Range("h2:h" & lrow).SpecialCells(xlCellTypeVisible).Count
If Myval >= "2" Then
Worksheets("Bin inventory").Range(Cells(VisRng.Offset(, 0).Row, 8), Cells(Range("g65536").End(xlUp).Row, 8)).Select
Send_Selection_Or_ActiveSheet_with_MailEnvelope
End If
End With
End Sub
Code:
Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2013
Dim Sendrng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Note: if the selection is one cell it will send the whole worksheet
Set Sendrng = Selection
'Create the mail and send it
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "This is a test mail."
With .Item
.To = "maricharm@cableone.net"
.CC = ""
.BCC = ""
.Subject = "My subject"
.Send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
Last edited by charlesdh; 03-10-2015 at 02:08 PM. Reason: Added info |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automatically add firm name to visible contactname | spqr² | Outlook | 0 | 12-29-2014 03:24 PM |
| Change formula cell range based on cell value | Scoth | Excel | 4 | 10-25-2012 07:51 AM |
| Email macro to read range for .To field | MattMurdock | Excel Programming | 2 | 08-07-2012 06:46 AM |
| Can't create new email or access email acounts Outlook 2003 | onthebeaches | Outlook | 1 | 02-20-2012 10:21 PM |
| Outlook Not Sending Automated Email Unless Visible | RMittelman | Outlook | 0 | 12-10-2010 11:18 AM |