OK, need some coding help please!!
I have 3 userforms. First one has three OptionButtons for the user to select their location. They then click an OK button. Second one has four CommandButtons that ask the user which data to import. The third userform consists of a listbox that gets filled with file names per the user's input in the first two userforms. I need help modifying the below codes to make sure the files being loaded into the listbox come from the correct server location based upon the answer in the first userform.
So, if user selects location A in the first userform (options A, B or C), then selects data X (options X, Y, Z or cancel) to be pulled in, the third userform needs to be filled with files from the location that corresponds with A and data files for X.
Right now I have the below code which fills the listbox, but it is only set for location A ("C:\Documents and Settings\username\My Documents\NA_Inventory"). How can I set it to pick up what the user inputs in userform 1?
I have one other question, but I may be able to figure it out myself after someone helps with this.
Thanks in advance.
I have 3 userforms. First one has three OptionButtons for the user to select their location. They then click an OK button. Second one has four CommandButtons that ask the user which data to import. The third userform consists of a listbox that gets filled with file names per the user's input in the first two userforms. I need help modifying the below codes to make sure the files being loaded into the listbox come from the correct server location based upon the answer in the first userform.
So, if user selects location A in the first userform (options A, B or C), then selects data X (options X, Y, Z or cancel) to be pulled in, the third userform needs to be filled with files from the location that corresponds with A and data files for X.
Right now I have the below code which fills the listbox, but it is only set for location A ("C:\Documents and Settings\username\My Documents\NA_Inventory"). How can I set it to pick up what the user inputs in userform 1?
Code:
Private Sub SacImport_Click()
Unload Me
' Declare filesearch object.
Set fs = Application.FileSearch
' Set folder to search. *****THIS IS WHERE I NEED HELP****
fs.LookIn = "C:\Documents and Settings\username\My Documents\NA_Inventory"
' Set file name to search for.
fs.Filename = "*US.xls"
' Execute the file search, and check to see if the file(s) are present.
If fs.Execute > 0 Then
' Redimension the array to the number of files found.
ReDim myarray(fs.FoundFiles.Count)
' Loop through all found file names and fill the array.
For i = 1 To fs.FoundFiles.Count
myarray(i) = fs.FoundFiles(i)
Next i
Else
' Display message if no files were found.
MsgBox "No files were found"
End If
' Loop through the array and fill the list box on the UserForm.
For i = 1 To fs.FoundFiles.Count
UserForm3.ListBoxFILES.AddItem myarray(i)
Next i
' Display the UserForm.
UserForm3.Show
End Sub
I have one other question, but I may be able to figure it out myself after someone helps with this.
Thanks in advance.