Hello,
I always get the following error-message:"Subscript out of range."
Please help me finding the mistake in the code. Thanks!!
Dim z As Integer
Dim Arr() As String
Dim intcounter As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Lists"
.FileType = msoFileTypeAllFiles
.Execute
For z = 1 To .FoundFiles.Count
If Left(.FoundFiles(z), 3) = "txt" Then
Arr(intcounter) = .FoundFiles(z)
intcounter = intcounter + 1
ReDim Preserve Arr(intcounter)
End If
Next z
End With
Sheets("navigation").ListBox1.List = Arr
I always get the following error-message:"Subscript out of range."
Please help me finding the mistake in the code. Thanks!!
Dim z As Integer
Dim Arr() As String
Dim intcounter As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Lists"
.FileType = msoFileTypeAllFiles
.Execute
For z = 1 To .FoundFiles.Count
If Left(.FoundFiles(z), 3) = "txt" Then
Arr(intcounter) = .FoundFiles(z)
intcounter = intcounter + 1
ReDim Preserve Arr(intcounter)
End If
Next z
End With
Sheets("navigation").ListBox1.List = Arr