Pass Data from List Boxes in Userform

E

ExcelMonkey

I have a Userform with 2 List boxes. Listbox1 loads all
the sheet names of the current workbook into it. The
user is then given the choice of ignorning certain
worksheets. The user chooses sheet names from Listbox1
and uses an ADD button to transfer these names into
Listbox2. The user then clicks on OK to continue. This
all works well.

I want to be able to create an array that summarizes
which sheets are of interest and not of interest. I want
to pull all the sheets names into an 2D array. I want
the first column to have the sheet names and the second
column to have a 1 (Interest) or 0 (Not Interested).

So my questiona are:
1) Where do I create this array? Is it in the OKButton
click Event?

2) I am effectively doing a lookup on the first column
values in my array (Sheet names) on the values in Listbox
2. I am not sure how to lookup a single value (from an
array) in a listbox.

TotalSheets = ListBox1.Items.Count

For X = 1 to TotalSheets
If Array(0,X-1) = ListBox2.?????? Then
Array(1,X-1) = 0
Else:
Array(1,X-1) = 1
End if
Next X


Does anybody know how to do this.

Thank-U
 
T

Tom Ogilvy

For X = 1 to TotalSheets
Array(1,X-1) = 1
for k = 0 to Listbox2.Listcount-1
if Listbox2.list(k) = Array(0,X-1) Then
Array(1,X-1) = 0
exit for
end if
Next
Next X
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top