Odabir pošaljite poštom koristeći VBA u programu Microsoft Excel

Anonim
  • Izradite novu radnu knjigu s odabirom.
  • Spremite radnu knjigu prije nego što je pošaljete.
  • Izbrišite datoteku s tvrdog diska nakon što je poslana.

Otkrivat će skrivene retke i stupce u odabiru
Sve prazne ćelije izvan odabira su skrivene (pogledajte snimak zaslona)
Na taj način odabir je uvijek na vrhu vašeg lista

Pod Mail_Selection () Dim strDate Kao String Dim Addr Kao String Dim rng As Range Ako ActiveWindow.SelectedSheets.Count> 1 Ili Selection.Areas.Count> 1 Zatim izađite iz Sub Application.ScreenUpdating = False Addr = Selection.Address ActiveSheet.Copy ActiveSheet. Slike.Brisanje sa ćelijama .EntireColumn.Hidden = False .EntireRow.Hidden = False End s rasponom (Addr). Odaberite Set rng = Application Selection.GoTo rng, True With rng.EntireColumn .Hidden = True rng (1) .EntireRow. SpecialCells (xlVisible) .EntireColumn.Clear rng (1) .EntireRow.SpecialCells (xlVisible) .EntireColumn.Hidden = True .Hidden = False End With With rng.EntireRow .Hidden = True rng (1). .EntireRow.Clear rng (1) .EntireColumn.SpecialCells (xlVisible) .EntireRow.Hidden = True .Hidden = False End With Application.GoTo rng, True rng.Cells (1). Odaberite strDate = Format (Datum, "dd- mm-yy ") &" "& Format (Vrijeme," h-mm-ss ") ActiveWorkbook.SaveAs" Dio "& ThisWorkbook.Name _ &" "& strDate &" .xls "ActiveWorkbook.SendM ail "[email protected]", _ "Ovo je naslov" ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName ActiveWorkbook.Close False Application.ScreenUpdating = True End Sub