|
-
Apr 25th, 2011, 10:05 AM
#1
Thread Starter
Junior Member
Select a few files in a folder
Dear All,
I wanted to select a few excel workbooks e.g. 3 out of 10 in a folder. How do i write the macro to do it?
example;
i have 20 workbooks in the same folder with same template. But, i wanted to select only 15 by highlighting the files that i need while the other 5 i do not want.
Thanks
NoobAvenger
-
Apr 25th, 2011, 03:34 PM
#2
Hyperactive Member
Re: Select a few files in a folder
What do you mean? Where are you selecting the 15 files? Are you wanting a file dialog box, or are you going to have a list within a workbook/other program where you select which ones you want?
-
Apr 25th, 2011, 10:46 PM
#3
Re: Select a few files in a folder
But, i wanted to select only 15 by highlighting the files that i need
where, how?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 25th, 2011, 11:11 PM
#4
Thread Starter
Junior Member
-
Apr 26th, 2011, 03:18 AM
#5
Re: Select a few files in a folder
i think application.filesearch is what you want, displays a dialog and returns a list of files to loop through
Last edited by westconn1; Apr 26th, 2011 at 03:22 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 27th, 2011, 03:12 AM
#6
Thread Starter
Junior Member
Re: Select a few files in a folder
Hi westconn,
I'm not sure how to use application.filesearch
Would appreciate if you can explain it to me. Thanks a lot. sorry for trouble
-
Apr 27th, 2011, 07:56 AM
#7
Re: Select a few files in a folder
my error, filesearch does not display a dialog, there is an application object that does, but it is not available in excel 2000, you will have to checkout in version 2003
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 27th, 2011, 04:02 PM
#8
Lively Member
Re: Select a few files in a folder
vb Code:
Dim FileLocationArray As Variant
FileLocationArray = Application.GetOpenFilename("Excel Files,*.xls", 1, "Select Multiple Files", , True)
For i = LBound(FileLocationArray) To UBound(FileLocationArray)
Application.Workbooks.Open FileLocationArray(i)
Next i
-
Apr 27th, 2011, 04:38 PM
#9
Re: Select a few files in a folder
doh!! you think i could remember getopenfilename?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 29th, 2011, 10:13 PM
#10
Thread Starter
Junior Member
Re: Select a few files in a folder
i've tried it and it is really what i wanted but how do i open one workbook at a time and do all the stuff that i want and then close it then open then next workbook?
sorry for trouble..
-
May 3rd, 2011, 07:58 AM
#11
Re: Select a few files in a folder
modify you code in post #4 to work with vanquishes code in post #7, use his for loop rather than your do loop
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|