Gruppe
Dialog
Problem
Wie kann ich aus allen Arbeitsmappen eines Verzeichnisses den jeweiligen Inhalt von Spalte A in eine UserForm-ListBox einlesen und danach in das aktive Blatt eintragen lassen?
ClassModule: frmDaten
Private Sub cmdWeiter_Click()
Dim iRow As Integer
For iRow = 0 To lstDaten.ListCount - 1
Cells(iRow + 1, 1).Value = lstDaten.List(iRow)
Next iRow
Unload Me
End Sub
StandardModule: basMain
Sub CallForm()
Dim iCounter As Integer, iRow As Integer
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error GoTo ERRORHANDLER
With Application.FileSearch
.LookIn = Range("C1").Value
.FileType = msoFileTypeExcelWorkbooks
.Execute
For iCounter = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(iCounter), False
With Range("A1").CurrentRegion
For iRow = 1 To WorksheetFunction.CountA(.Columns(1))
frmDaten.lstDaten.AddItem Cells(iRow, 1).Value
Next iRow
End With
ActiveWorkbook.Close savechanges:=False
Next iCounter
End With
frmDaten.Show
ERRORHANDLER:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub