Hi Guys
I am looking to populate 2 different listboxes but the files i wish to fill into the listbox are in the same folder.
Currently i can get the code to fill listbox1 with all files but 1, which is put in the second listbox...
I have been looking at a lot of threads, but i can't seem to find identical issues.
I am looking to populate 2 different listboxes but the files i wish to fill into the listbox are in the same folder.
Currently i can get the code to fill listbox1 with all files but 1, which is put in the second listbox...
I have been looking at a lot of threads, but i can't seem to find identical issues.
Code:
Private Sub UserForm_Initialize()
'x is a variable that is use to change the folder path in the userform
If x = 0 Then
TextBox1.Value = Year(Now)
TextBox2.Value = Month(Now)
Else
TextBox1.Value = TextBox1.Value
TextBox2.Value = TextBox2.Value
End If
fpath = ThisWorkbook.Path & "\Extracts\" & TextBox1.Value & "\" & TextBox2.Value & "\"
orderfile = Dir(fpath & "Order*.xls*", vbNormal)
stockfile = Dir(fpath & "Lager*.xls*", vbNormal)
ListBox1.Clear
ListBox2.Clear
Call CheckFolder
'Do While stockfile <> ""
Do While Len(orderfile) > 0
ListBox1.AddItem orderfile
orderfile = Dir(orderfile)
Loop
Do While Len(stockfile) > 0
ListBox2.AddItem stockfile
stockfile = Dir()
Loop
x = 0
Stop
End Sub
Private Sub CheckFolder()
If Dir(fpath & "\*.*") = "" Then
MsgBox "There are no files available" & vbNewLine & "Please save stockfile in the following folder:" & vbNewLine & fpath
End If
End Sub
[\Code]