ich bastel gerade an einem Script zum versenden von Informationen aus einer Excel Tabelle per Mail, wo eine seperate Excel Tabelle als Anhang mitgeschickt wird, nur mit ausgewählten Bereichen.
Es Funktioniert soweit alles, bis auf das ich mehrere Zellbereiche einfügen kann.
Bis jetzt funktioniert nur das der Bereich A10:D20 in die neue Datei kopiert wird.
Ändere ich:
Set Source = Range("A10:D20", "M30:Q50").SpecialCells(xlCellTypeVisible)
bekomme ich alles von A10 - Q50 kopiert.
Wo ist mein Fehler?
Danke und Grüße
[code]
Sub Mail_EDV()
Const SEP$ = " "
Dim Source As Range
Dim Dest As Workbook
Dim Wb As Workbook: Set Wb = ThisWorkbook
Dim Ws As Worksheet: Set Ws = Wb.ActiveSheet
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim OutApp As Object
Dim OutMail As Object
Dim Txt$, c As Range
Dim Ol As Object, OlCreate As Boolean
'Mitarbeiter Informationen kopieren
Set Source = Nothing
On Error Resume Next
Set Source = Range("A10:D20").SpecialCells(xlCellTypeVisible)
'Set Source = Range("A10:D20").Select
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, please correct and try _
again.", vbOKOnly
Exit Sub
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = Wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
If Val(Application.Version)
[/code]