Envie a seleção usando VBA no Microsoft Excel

Índice
  • Crie uma nova pasta de trabalho com a Seleção.
  • Salve a pasta de trabalho antes de enviá-la.
  • Exclua o arquivo do disco rígido depois de enviá-lo.

Irá exibir as linhas e colunas ocultas na seleção
Todas as células vazias fora da seleção estão ocultas (veja a imagem)
Desta forma, a seleção está sempre no topo da sua planilha

Sub Mail_Selection () Dim strDate As String Dim Addr As String Dim rng As Range If ActiveWindow.SelectedSheets.Count> 1 Or Selection.Areas.Count> 1 Then Sair Sub Application.ScreenUpdating = False Addr = Selection.Address ActiveSheet.Copy ActiveSheet. Pictures.Delete With Cells .EntireColumn.Hidden = False .EntireRow.Hidden = False End With Range (Addr) .Select Set rng = Seleção 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.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) .Selecione strDate = Format (Date, "dd- mm-aa ") &" "& Format (Time," h-mm-ss ") ActiveWorkbook.SaveAs" Part of "& ThisWorkbook.Name _ &" "& strDate &" .xls "ActiveWorkbook.SendM ail "[email protected]", _ "Esta é a linha do Assunto" ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName ActiveWorkbook.Close False Application.ScreenUpdating = True End Sub

Você vai ajudar o desenvolvimento do site, compartilhando a página com seus amigos

wave wave wave wave wave