Hey,
I have a bunch of files with similar names but I only need to list the ones that contain "#" character. I tried a couple of ways but no luck.
it always adds the whole list and not just the one file I have ...I don't get why Dir function is working properly and the next one not
Any ideas?
Thanks
I have a bunch of files with similar names but I only need to list the ones that contain "#" character. I tried a couple of ways but no luck.
Code:
File list:
Intercompany Recs Bulgaria # 0059.xlsb
Intercompany Recs Bulgaria ∣ 0059 - Copy.xlsb
Intercompany Recs Bulgaria ☠ 0059.xlsb
Intercompany Recs Bulgaria ☢ 0059 - Copy.xlsb
Intercompany Recs Bulgaria ✲ 0059 - Copy (3).xlsb
Intercompany Recs Bulgaria ☕ 0059 - Copy (2).xlsb
Code:
Private Sub PeriodBox_Click()
Dim Recs As String
If Dir(path & "\Intercompany Recs * # *") <> "" Then 'this part of code returns only the # file as expected
Recs = Dir(path & "\")
Do While Recs <> ""
If Recs Like "Intercompany Recs * # *" Then FileBox.AddItem "IC Rec | " & Right(Recs, 9)
Recs = Dir
Loop
End Sub
[B]OR I also tried[/B]
Private Sub PeriodBox_Click()
Dim Recs, hash As String
hash = Chr(35)
If Dir(path & "\Intercompany Recs * # *") <> "" Then 'this part of code returns only the # file as expected
Recs = Dir(path & "\")
Do While Recs <> ""
If Recs Like "Intercompany Recs *" & hash & "*" Then FileBox.AddItem "IC Rec | " & Right(Recs, 9)
Recs = Dir
Loop
End Sub
it always adds the whole list and not just the one file I have ...I don't get why Dir function is working properly and the next one not
Any ideas?
Thanks
Last edited: