Hi
I am using Instr to compare filenames in a directory against those in an array.
Unfortunately because some of the files have the same name apart from '- ST' they are seen as the same by the InStr func.
I could reverse their positions and this does work but I wanted to keep the file order as it is.
Any suggetions? Is their another function I can use to match filenames in the array?
I am using Instr to compare filenames in a directory against those in an array.
Unfortunately because some of the files have the same name apart from '- ST' they are seen as the same by the InStr func.
I could reverse their positions and this does work but I wanted to keep the file order as it is.
Any suggetions? Is their another function I can use to match filenames in the array?
Code:
'Array of file names
arrFile = Array[COLOR=red]("File1", [/COLOR][COLOR=darkgreen]"[COLOR=red]File1[/COLOR] [/COLOR][COLOR=darkred][B]- ST[/B]",[/COLOR] [COLOR=blue]"File2", [/COLOR][COLOR=purple][COLOR=blue]"File2[/COLOR] [/COLOR][COLOR=darkred][B]- ST",[/B][/COLOR] "File3", _
"File4", "File5")
SampleFile = Dir("*.dat")
Do While SampleFile <> ""
For arrIndex = LBound(arrFile) To UBound(arrFile)
If InStr(SampleFile, arrFile(arrIndex)) > 0 Then
FileMatched = True
Select Case arrIndex
Case Is = 0
Rng = "B2"
Case Is = 1
Rng = "B3"
Case Is = 2
Rng = "B4"
Case Is = 3
Rng = "B5"
Case Is = 4
Rng = "B7"
Case Is = 5
Rng = "B11"
Case Is = 6
Rng = "B12"
End Select
[/Code