View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Stu[_34_] Stu[_34_] is offline
external usenet poster
 
Posts: 2
Default Reload Listbox - type mismatch error

I've created to arrays that hold the sheet names for a worksheet,
mySheetList() which holds the natural sheet order and
mySheetListAlpha() which holds a the sheet names alphabetically
ordered. I want to offer the user a form containing a listbox with the
sheetnames and two buttons on the form that the user select either
natural order or alphabetically ordered. By clicking on the buttons,
the listbox is dynamically updated with either one of the two arrays.
I call a list box via UserForm_Initialize() and populate the list with:


ListBox1.List = mySheetList

This part works well (I can also get the listbox populated
alphabetically with ListBox1.List = mySheetListAlpha). My problem lies
in trying to update the listbox with the second array. On the form is
a command button with the following code

Listbox.Clear
For X = LBound(mySheetListAlpha) To UBound(mySheetListAlpha)
ListBox1.AddItem mySheetListAlpha(X)
Next

The listbox.clear command clears the listbox but the second line of
code causes Type Mismatch error. Can someone tell me how I can
repopulate the listbox with values held in the second array.

Thanks