Hallo zusammen,
kann man eine meinen Code so optimieren, damit der Export automatisch erfolgt, wenn man den PC startet, ohne dass man die Excel-Datei öffnet? Oder muss man das wo anders programmieren?
Sub ImportData()
Dim x As Workbook, y As Workbook
Dim lz As Integer, n As Integer
Set x = Workbooks.Open("D:....")
Set y = ThisWorkbook
lz = x.Sheets("Tabelle1").Cells(Rows.Count, "A").End(xlUp).Row
m = 2
For n = 2 To lz
If x.Sheets("Tabelle1").Cells(n, 1).Value = "Name1" Or _
x.Sheets("Tabelle1").Cells(n, 1).Value = "Name2" Or _
x.Sheets("Tabelle1").Cells(n, 1).Value = "Name3" Or _
x.Sheets("Tabelle1").Cells(n, 1).Value = "Name4" Or _
x.Sheets("Tabelle1").Cells(n, 1).Value = "Name5" Or _
x.Sheets("Tabelle1").Cells(n, 1).Value = "Name6" Then
y.Sheets("Versuch1").Range(y.Sheets("Versuch1").Cells(m, 1), y.Sheets("Versuch1").Cells(m, 8)).Value = x.Sheets("Tabelle1").Range(x.Sheets("Tabelle1").Cells(n, 1), x.Sheets("Tabelle1").Cells(n, 8)).Value
m = m + 1
End If
Next n
x.Close
End Sub
Grüße
Andi
|