ich brauche mal wieder euer Hilfe. Undzwar kann mir jemand sagen wie ich mit Makro eine Datei öffne. Dann aus der Datei in der Spalte A suche, diese Daten dann kopiere und in der Such Datei einfüge und dann die Datei schließe.
Gruss Betro
Sub SucheInDat()
Dim strSuchtext As String
Dim lngLetzteZeile As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open "H:\Excel\Muell\Data.xls"
strSuchtext = InputBox("Bitte einen Suchtext eingeben!", "Suchtext für suchen in Data", "Text")
On Error GoTo nix
If strSuchtext <> "" And strSuchtext <> "Falsch" Then
Workbooks("data").Sheets("Tabelle1").Range("A:A").Find(strSuchtext).Activate
ActiveCell.EntireRow.Copy
On Error goto 0
lngLetzteZeile = Workbooks("Suche").Sheets("Tabelle1").Cells(Rows.Count, 1).End(xlUp).Row
Workbooks("Suche").Activate
Sheets("Tabelle1").Cells(lngLetzteZeile + 1, 1).Select
ActiveCell.PasteSpecial
Sheets("Tabelle1").Cells(lngLetzteZeile + 1, 1).Select
End If
Workbooks("data").Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
nix:
MsgBox "Der Suchtext ist in Tabelle Data.xls Spalte A nicht vorhanden", vbInformation
Workbooks("data").Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Sub SucheInDat()
Dim strSuchtext As String
Dim lngLetzteZeile As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open "Data.xls"
strSuchtext = InputBox("Bitte einen Suchtext eingeben!", "Suchtext für suchen in Data", "A-571")
On Error GoTo nix
If strSuchtext <> "" And strSuchtext <> "Falsch" Then
Workbooks("data").Sheets("Aufträge").Range("A:A").Find(strSuchtext).Activate
On Error GoTo 0
Set Db = Sheets("Suche")
With Sheets("Data")
ActiveCell.Offset(0, 1).Copy Db.Range("Modell").End(xlDown)
ActiveCell.Offset(0, 2).Copy Db.Range("ANr).End(xlDown)
ActiveCell.Offset(0, 1).Copy Db.Range("Datum").End(xlDown)
End With
End If
Workbooks("data").Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
nix:
MsgBox "Der Suchtext ist in Tabelle Data.xls Spalte A nicht vorhanden", vbInformation
Workbooks("data").Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub