Anbei der Quelltext (einzelne Werte musste ich aus Datenschutzgründen anpassen, funktionieren sollte es trotzdem noch.

Option Explicit

Dim i As Integer

Dim a As Integer

Dim c As Integer

Dim mail As String

Dim techniker As String

Dim art As String

Dim MyDate As Date

Dim filename As String

Sub CopyTest()

'Fehlermeldungen Deaktivieren

Application.ScreenUpdating = True

Application.DisplayAlerts = False

'Start

OpenWorkbooks

'Anzahl der der Loop Zeilen

a = 100

c = 0

'Loop start

For i = 1 To a 'run the loop until field is empty

'--------------------------------------------------------------------------------------------

If Workbooks("Export.xlsx").Sheets("Tickets").Range("J" & 1 + i) <> " " Then

  If Workbooks("Export.xlsx").Sheets("Tickets").Range("E" & 1 + i) <> "??" Then

    If Workbooks("Export.xlsx").Sheets("Tickets").Range("X" & 1 + i) = " Störung" Then

      c = c + 1

    CopyData

    End If

  End If

End If

'--------------------------------------------------------------------------------------------

'Loop end

Next i

' Export schließen

Workbooks("Export.xlsx").Close SaveChanges:=False

'Datei als csv exportieren

FileExport

'Template schließen

Workbooks("Template.xlsx").Close SaveChanges:=False

'Fehlermeldungen aktivieren

Application.DisplayAlerts = True

Application.ScreenUpdating = False

End Sub

Function OpenWorkbooks()

'Öffnet das Template

Workbooks.Open "Template.xlsx"

'Öffnet den MKS-Export

Workbooks.Open "Export.xlsx"

End Function

Function CopyData()

'Feste Werte

Workbooks("Template.xlsx").Sheets("Template").Range("W" & 1 + c) = "Ort" 'Region

Workbooks("Template.xlsx").Sheets("Template").Range("R" & 1 + c) = land

Workbooks("Template.xlsx").Sheets("Template").Range("Q" & 1 + c) = "land 2" 'Country

Workbooks("Template.xlsx").Sheets("Template").Range("J" & 1 + c) = 1 'SR_Source

Workbooks("Template.xlsx").Sheets("Template").Range("E" & 1 + c) = 10 'Sprache

Workbooks("Template.xlsx").Sheets("Template").Range("C" & 1 + c) = 3 'Gender

Workbooks("Template.xlsx").Sheets("Template").Range("AN" & 1 + c) = "" 'Team

Workbooks("Template.xlsx").Sheets("Template").Range("AS" & 1 + c) = "Mail1" 'Escalation Mail 1

Workbooks("Template.xlsx").Sheets("Template").Range("AT" & 1 + c) = "Mail2" 'Escalation Mail 2

Workbooks("Template.xlsx").Sheets("Template").Range("AU" & 1 + c) = "Mail3" 'Escalation Mail 3

'Dynamische Werte

Workbooks("Template.xlsx").Sheets("Template").Range("A" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("G" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("B" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("F" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("D" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("J" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("F" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("I" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("H" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("C" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("O" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("E" & 1 + i) '

Workbooks("Template.xlsx").Sheets("Template").Range("G" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("A" & 1 + i) '

Workbooks("Template.xlsx").Sheets("Template").Range("AO" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("AH" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("AP" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("U" & 1 + i)

Workbooks("Template.xlsx").Sheets("Template").Range("AM" & 1 + c) = Workbooks("Export.xlsx").Sheets("Tickets").Range("Z" & 1 + i)

End Function

Function FileExport()

'Variablen Für Dateipfad

Dim myCSVFileName As String

Dim tempWB As Workbook

'Datum Formatieren

MyDate = Date

'Dateinamen erstellen

FileFormat

'Dateispeicherort festlegen

myCSVFileName = "Pfad" & filename

'Tabellenblatt auswählen

ActiveSheet.Copy

Set tempWB = ActiveWorkbook

'Speichervorgang

With tempWB

  tempWB.SaveAs filename:=myCSVFileName, FileFormat:=xlCSVUTF8

  tempWB.Close

End With

   

'Workbooks("Template.xlsx").Close SaveChanges:=False

End Function

Function FileFormat()

'Variablen für Dateinamen

Dim part1 As String

Dim part2 As String

Dim part3 As String

'Wertzuweisung

part1 = "_"

part3 = "_"

MyDate = Date

part2 = Format(Date, "yyyymmdd")

filename = part1 & part2 & part3 & ".csv"

End Function

...zur Antwort