title: Filter and Email Excel File (VBA)
body: <p>I have a list of accounts and relevant information that I have to split up and send specific accounts to certain people.  This has to be done about 50 times.  I already have a program setup that will filter, copy the data to a new file, and save.  Is there a way to set it up to then email this file based on a list of contacts?</p>
  
  <p>Each account is covered by a region, so I have a list which has the region and the contact's email.  In the macro that splits by the regions, it has an array of these regions so is some kind of lookup possible from the list of contacts?</p>
  
  <p>Code:</p>
  
  <pre><code>Sub SplitFile()
  
  Dim rTemp As Range
  Dim regions() As String
  
  Set rTemp = ThisWorkbook.Sheets("Combined").Range("AH2:AH1455")
  regions = UniqueItems(rTemp, False)
  For N = 1 To UBound(regions)
      Set wb = Workbooks.Add
  
      ThisWorkbook.Sheets("DVal").Copy _
         after:=ActiveWorkbook.Sheets("Sheet1")
  
      With ThisWorkbook.Sheets("Combined")
          .AutoFilterMode = False
  '        .AutoFilter
          .Range("A1:BP1455").AutoFilter Field:=34, Criteria1:=regions(N)
                Application.DisplayAlerts = False
          .Range("A1:BP1455").Copy wb.Sheets("Sheet1").Range("A1")
                Application.DisplayAlerts = True
          For c = 1 To 68
              wb.Sheets("Sheet1").Range("A1:BP2694").Columns(c).ColumnWidth = .Columns(c).ColumnWidth
          Next c
      End With
  
      With wb
          .Sheets("Sheet1").Activate
          .SaveAs Filename:="H:\" &amp; regions(N) &amp; " 14-12-11"
          .Close True
      End With
  
      Set wb = Nothing
  Next N
  
  End Sub
  </code></pre>