This suffices:
Code:Sub M_snb() Sheets.Add.Name = "transport" For Each it In Filter([transpose(if(countif(offset(tempquery!H2,,,row(H2:H10)-1),tempquery!H2:H10)=1,tempquery!H2:H10))], False, False) Sheets("transport").UsedRange.ClearContents With Sheets("tempQuery").Cells(1).CurrentRegion .AutoFilter 8, it c01 = Sheets("tempquery").Columns(9).SpecialCells(12)(2) .Copy Sheets("transport").Cells(1) .AutoFilter End With Sheets("transport").Copy ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & it & ".xlsx", 56 ActiveWorkbook.Close With CreateObject("outlook.application").createitem(0) .to = c01 .Subject = "new file" .attachments.Add ThisWorkbook.Path & "\" & it & ".xlsx" .send End With Next End Sub




Reply With Quote
Bookmarks