ich habe ein kleines Problem, wo ich euren Rat bräuchte.
Ich habe hier ein Makro gefunden, welches mir aus diversen Exceldateien eine Zelle auslesen kann.
Option Explicit
Const strSheetQ As String = "THT-Handbest." ' Die Tabelle wird ausgelesen
Const strSheetZ As String = "Tabelle1" ' Die Tabelle in dieser Datei
Const strCellQ1 As String = "K38" ' Die Zelle wird ausgelesen ;F38;F40
Public Sub Files_Read()
Dim stCalc As Integer
Dim strDir As String
Dim objFSO As Object
Dim objDir As Object
On Error GoTo Fin
With Application
.ScreenUpdating = False
.AskToUpdateLinks = False
.EnableEvents = False
stCalc = .Calculation
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With
Set objFSO = CreateObject("Scripting.FileSystemObject")
strDir = ThisWorkbook.Path ' Datei im gleichen Ordner wie Auswertungsdateien
Set objDir = objFSO.GetFolder(strDir)
'dirInfo objDir, "*.xl*", True ' Mit Unterordner
dirInfo objDir, "*.xl*"
Fin:
With Application
.ScreenUpdating = True
.AskToUpdateLinks = True
.EnableEvents = True
.Calculation = stCalc
.DisplayAlerts = True
End With
Set objDir = Nothing
Set objFSO = Nothing
End Sub
Public Sub dirInfo(ByVal objCurrentDir As Object, ByVal strName As String, _
Optional ByVal blnTMP As Boolean = False)
Dim objWorkbook As Workbook
Dim strFormula As String
Dim lngLastRow As Long
Dim varTMP As Variant
For Each varTMP In objCurrentDir.Files
If varTMP.Name Like strName And varTMP.Name ThisWorkbook.Name Then
If Not Left(varTMP.Name, 2) = "Q_" Then
With ThisWorkbook.Worksheets(strSheetZ)
lngLastRow = IIf(Len(.Cells(.Rows.Count, 2)), _
.Rows.Count, .Cells(.Rows.Count, 2).End(xlUp).Row) + 1
With .Cells(lngLastRow, 2)
.Formula = "='" & Mid(varTMP.Path, 1, _
InStrRev(varTMP.Path, "\")) & "[" & _
Mid(varTMP.Path, InStrRev(varTMP.Path, "\") + 1) & "]" & _
strSheetQ & "'!" & strCellQ1
.Value = .Value
.Offset(0, -1).Value = varTMP.Name
End With
End With
End If
End If
Next
If blnTMP = True Then
For Each varTMP In objCurrentDir.SubFolders
dirInfo varTMP, strName
Next varTMP
End If
Set objWorkbook = Nothing
End Sub
Das ist genau das was ich auch benötige.Allerdings würde ich nicht nur eine Zelle rausschreiben wollen, sondern mehrere.
Ich weiß nun nicht ob man das nun mit einer Schleife macht, oder einfacher lösen kann?
Könnte gut Hilfe gebrauchen, wie ich das auf mehrere Zellen ausweiten kann...
Schönen Abend
Gruß
Stefan