View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
dirt dirt is offline
external usenet poster
 
Posts: 9
Default combo box and .listindex

to populate the combobox:

Private Sub UserForm_Activate()
'populate the Category combo box

With ufNewAlbum.cobCategory
.RowSource = ""
For i = 4 To 13
.AddItem Sheets("Inputs").Cells(i, 14)
Next i

End With

End Sub

to transfer the list index value to a specific sheet and cell:

Private Sub cobCategory_Click()
' record user selection
Selection = ufNewAlbum.cobCategory.ListIndex

Sheets("Inputs").Cells(14, 15).Value = Selection

End Sub

to close and reset the listindex:

Private Sub CommandButton2_Click()
'close without update
ufNewAlbum.cobCategory.ListIndex = -1 'clear the reference to music category

ufNewAlbum.Hide 'hide the userform

End Sub

I found that I cannot use a reference to a sheet other than the active sheet to set the combobox properties - such as control source, listindex, etc. Any reference to another sheet (ie:sheets("blahblah").range("moreblah")) doesn't work.

I hope this is clearer, the code I have will work for me despite the apparent limitations on the property assignment, but I need to eliminate the mysterious display of the .listindex value on the active cell!

Thanks again,

Dan


"Bob Kilmer" wrote in message ...
How are you coding the assignment? Are you assigning it to a cell in the
active sheet, inadvertently. Show us some code, eh?

"dirt" wrote in message
. ..
I have a combobox on a user form that I populate using the .additem

method.
I want the listindex to be displayed on a worksheet that is hidden. I can
do this by assigning the .listindex property to the sheet and cell.
However, when the user selects an item from the combo box, the ..listindex
integer also appears in whichever cell was active (wherever the cursor is

in
the active sheet) when the user triggered the userform.

My question, how do I prevent the .listindex from being copied to the

active
cell?

TIA,

D