Legg til nytt ark, endre bladnavnet til post.
Hver e -post du vil sende vil bruke tre kolonner.
- i kolonne A - skriv inn ark eller arknavn du vil sende.
- i kolonne B - skriv inn e -postadresse.
- i kolonne C - emnetittelen vises øverst i e -postmeldingen.
Kolonne A: C angi informasjon for den første e -posten, og du kan bruke kolonner D: F for den andre.
Du kan sende 85 forskjellige e-poster på denne måten (85*3 = 255 kolonner).
Sub Mail_sheets () Dim MyArr As Variant Dim last As Long Dim shname As Long Dim a As Integer Dim Arr () As String Dim N As Integer Dim strdate As String For a = 1 To 253 Step 3 If ThisWorkbook.Sheets ("mail" ) .Cells (1, a) .Value = "" Avslutt deretter Sub Application.ScreenUpdating = False last = ThisWorkbook.Sheets ("mail"). Celler (Rows.Count, a) .End (xlUp) .Rad N = 0 For shname = 1 For å vare N = N + 1 ReDim Preserve Arr (1 To N) Arr (N) = ThisWorkbook.Sheets ("mail"). Celler (shname, a) .Value Next shname ThisWorkbook.Worksheets (Arr). Copy strdate = Format (Date, "dd-mm-yy") & "" & Format (Time, "h-mm-ss") ActiveWorkbook.SaveAs "Part of" & ThisWorkbook.Name _ & "" & strdate & " .xls "With ThisWorkbook.Sheets (" mail ") MyArr = .Range (.Cells (1, a + 1), .Cells (Rows.Count, a + 1). End (xlUp)) End with ActiveWorkbook.SendMail MyArr , ThisWorkbook.Sheets ("mail"). Celler (1, a + 2) .Value ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName ActiveWorkbook.Close False Application.ScreenUpdating = True Next a Slutt Sub