Hi guys. This may be a silly question, so I hope you'll forgive me - I am still quite new to VBA. Basically I've been asked to make a slight adjustment to an existing project, as follows:
A button in the worksheet opens a dialog box, which contains a list of filenames, one or more of which the user selects before clicking the "OK" button which starts an export process (for reports and the like). The file list is quite long and I've been asked to add something that allows you to select all the files at once.
My thinking is to add a button to the dialog box called "Select All" and then in the Click() section for this button some code which selects all the files. The problem is, I'm not too sure how this code might look (or indeed if it is possible). I tried to record a macro of ctr-clicking all the files, but it didn't record (I assume you can only record from the spreadsheet itself).
Anyway, if anyone could provide some thoughts (even if just to say whether it is or isn't possible) I'd really appreciate it.
Thanks in advance,
Simon.
Are you talking about a ListBox on a UserForm?
If that's what you are using
Option Explicit Private Sub chkAll_Click() Dim i As Integer For i = 1 To lbxSheets.ListCount Me.lbxSheets.Selected(i - 1) = Me.chkAll.Value Next i End Sub
Last edited by royUK; 12-16-2010 at 02:40 PM.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Hi, thanks for replying.
No I don't think it's a list box. There's an activeX button on the spreadsheet, and pushing that opens a dialog box which has a list of files. You can select one or ctrl-click and select multiple files, and then when you click OK these files are exported.
I can add a new button (apart from the "OK" and "Cancel" ones that are already there) and am wondering if I can add some code to the new button's Click() section which will select all the files in the list.
Thanks again for your help.
Simon
To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.
If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.
Doing this will ensure you get the result you need!
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks