ich habe 6 Tabellenblätter.
hier mache ich eine Abfrage nach ein Datum, ob dieses in der entsprechenden Zeile drin steht.
wenn das Datum drin steht, dann möchte ich von der Zeile Spalte B und C kopieren und in ein neues Tabellenblatt einfügen.
und das ganze für alle 6 Tabellenblätter
Datum steht immer in Spalte D
Bsp.
Tabelle1
Datum gefunden in Zelle "D20"
Kopiert werden soll "B20:C20"
eingefügt in Tabelle9
kann man dabei jemand helfen?
danke schon einmal
Code bisher:
Sub auslesen2()
Dim Zeile, Spalte, Zletzte As Long
Dim Datum As Variant
Dim wks, wksActive As Variant
Dim x As String
Dim rng As Range
wksActive = ActiveSheet.Name
x = InputBox("Datum eingeben", "Datumsabfrage", Format(CDate(Now()), "dd.mm.yyyy"))
If IsNumeric(x) Then
Datum = Format(x, "DD.MM.")
ElseIf x = "" Then
Exit Sub
End If
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
For wks = 1 To Worksheets.Count
Sheets(wks).Select
For Zeile = 2 To Cells(Rows.Count, 2).End(xlUp).Row
Set rng = ActiveSheet.Cells(Zeile, 4).Find(Datum)
If Not rng Is Nothing Then
' hier kopieren
End If
Next Zeile
If wks = 7 Then Exit For
Next wks
With Sheets(9)
.Select
'hier einfügen
If Not .PageSetup.PrintArea = "$A$1:$D$" & Zletzte Then
.PageSetup.PrintArea = "$A$1:$D$" & Zletzte
End If
.Range("G1").Value = Format(x, "DD.MM.YYYY")
End With
Sheets(wksActive).Select
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub