Saatke valik postiga Microsoft Excelis VBA abil

Anonim
  • Looge valikuga uus töövihik.
  • Salvestage töövihik enne selle saatmist.
  • Pärast saatmist kustutage fail kõvakettalt.

See kuvab valikus peidetud read ja veerud
Kõik tühjad lahtrid väljaspool valikut on peidetud (vt ekraanipilti)
Nii on valik alati lehe peal

Alampost_valik () Dim strDate Stringina Dim Addr String Dim rng vahemikuna kui ActiveWindow.SelectedSheets.Count> 1 Või Selection.Areas.Count> 1 Seejärel väljuge alamrakendusest. ScreenUpdating = False Addr = Selection.Address ActiveSheet.Copy ActiveSheet. Pildid. Kustutage lahtritega .EntireColumn.Hidden = False .EntireRow.Hidden = Vale lõpp vahemikuga (Addr). Valige Set rng = Selection Application.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) .EntireColumn.SpecialCells (xlVisible). .EntireRow.Clear rng (1) .EntireColumn.SpecialCells (xlVisible) .EntireRow.Hidden = True .Hidden = False End With Application.GoTo rng, True rng.Cells (1). Valige strDate = Format (Date, "dd- mm-yy ") &" "& Format (Time," h-mm-ss ") ActiveWorkbook.SaveAs" Osana "& ThisWorkbook.Name _ &" "& strDate &" .xls "ActiveWorkbook.SendM ail "[email protected]", _ "See on teemarea" ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName ActiveWorkbook.Close False Application.ScreenUpdating = True End Sub