I have a folder with 3 excel files ,and i want to read the files with names,and get a substring from the name of excel file,My code is working fine but the issue is when it reads the substring,it does not read the very first file ,the code is here :
Wend
when i debug,it reads the first file till strFile = Dir() after that it goes to the second excel file and leaves the first file.I need help here .Thanks
Code:
strFile = Dir(strPath & "*.xlsm")
While strFile <> ""
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
[COLOR=red]strFile = Dir()[/COLOR]
'Reads the substring(the Lot# from the name of the file)
intPos = InStr(1, strFile, ")")
If intPos > 0 Then
' : found, so take up to :
strResult = Left(strFile, intPos - 1)
MsgBox (strResult)
Else
' : not found, so take whole string
strResult = strFile
' MsgBox (strResult)
End If
Wend
when i debug,it reads the first file till strFile = Dir() after that it goes to the second excel file and leaves the first file.I need help here .Thanks
Last edited: