I have added a filter to the type of files allowed to selected (.dat files) however I have found that if there are zip files present in the folder the script does not work correctly as it also opens the zip files.
'Specify folder where measurement files are stored
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = True Then
MyFolder = .SelectedItems(1)
Else
Exit Sub
End If
End With
Sheet8.Columns.ClearContents
sFile_Name = Dir(MyFolder & "\*.dat*")
Do While sFile_Name <> ""
Set wsData_Sheet = Sheet5
j = wsData_Sheet.Cells(1, Columns.Count).End(xlToLeft).Column
jn = j + 1
lcl = Sheet8.Cells(2, Columns.Count).End(xlToLeft).Column
lclp = lcl + 1
Call PARSE_MDF(MyFolder & "\" & sFile_Name, jn, sEND, lclp)
sFile_Name = Dir()
Loop
How do I exclude zip files and limit it to only .dat files?
I'm guessing that your zip files may also hold the string
.dat
somewhere in them (such asfile.dat.zip
for example) because this snippet:will give you all files containing
.dat
, not all those ending in.dat
.If you only want the latter, try:
(without the final
*
).