Select multiple files to insert in Excel

evnoort

Board Regular
Joined
Aug 16, 2011
Messages
52
Hi all, I have witten code to insert lines of all txt files in a folder into a excel file.
I used SHBrowseForFolder to select a folder. used code from here: http://j-walk.com/ss/excel/tips/tip29.htm

But I now need to select only a few files from a folder. So a (visual) multiple select.
Any of you got an idea how I can do this. The Folderview control does not seem to do the job.
Do I need to build a user form to do this or is there a better (easyer) way
regards.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
try something like this...

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Open_Multi_Files()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br><br>    <SPAN style="color:#007F00">' Prompt user to select a files</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Application.FileDialog(msoFileDialogOpen)<br>        .InitialFileName = "C:\Temp\"               <SPAN style="color:#007F00">' Default path</SPAN><br>        .FilterIndex = 3<br>        .Title = "Please Select File(s): Ctrl+Click to select multiple files"<br>        .ButtonName = "Open"<br>        .AllowMultiSelect = <SPAN style="color:#00007F">True</SPAN><br>        .Show<br>        <SPAN style="color:#00007F">If</SPAN> .SelectedItems.Count = 0 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>   <SPAN style="color:#007F00">' User clicked cancel</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> .SelectedItems.Count<br>            <SPAN style="color:#007F00">'Open each selected file</SPAN><br>            Workbooks.Open Filename:=.SelectedItems(i)<br>        <SPAN style="color:#00007F">Next</SPAN> i<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,969
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top