Reputation: 133
I'm trying to get some data out of excel files. Never used excel before but I understand VB. So I have a file with a button my boss implemented as well as his code he used. Here is the code:
(you can see the "Get Data" button in there) My exact problem is that I don't know a lot about excel so if someone could help me figure out what is going on as well as figuring out how to correctly use directories that would be awesome! For more context when you click the button it gets all files in the directory and then the user clicks a file then excel follows a macro to get some data out of sed file.
Right now it returns nothing but there is 5 files in that directory?
Here is what the default directory looks like after edit: And here is the files in my directory:
Upvotes: 1
Views: 56
Reputation: 5386
As @Tim Williams says ... Insert the back slash after the folder name
DirNow = Dir(Range("DefaultDirectory") + "\WFP*", vbDirectory)
EDIT
Basic troublseshooting
Does it it compile? Looks like "UserFormDataa" - should maybe be "UserFormData"
Add Debug.Print DirNow after it's set and show us the display
If that's not right add line Debug.Print Range("DefaultDirectory") to makes sure range is defined properly
Remove vbDirectory - unless you're going to handle processing files under the matching sub-folders
Upvotes: 1
Reputation: 166126
You are missing the terminal backslash on your default directory.
C:\Users\CUCCOMTT\Desktop\Excel Project\
Otherwise you're looking for files named
C:\Users\CUCCOMTT\Desktop\Excel ProjectWFP
Upvotes: 1