View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] googlegroups.5.ericg@spamgourmet.com is offline
external usenet poster
 
Posts: 1
Default Listindex problems in multicolumn listbox

I have a form button that toggles something on and off. The state is
kept in a cell which says "on" or "off". The second column of my
two-column listbox indicates the state. The appropriate item in the
second column is being updated when I click the toggle button. My
problem is that, after the listbox is updated, I can't use listindex to
cause the row that was selected to be solected again. If I comment out
the "Call FillWorkbookListbox" line, everything is fine, but I need to
make that call. After clicking the toggle button, the listbox is
updated fine, but no row at all is selected, although if I keep
clicking the toggle button, the appropriate item in the second column
continues to toggle. What am I doing wrong?

Private Sub Button_TogglexlStart_Click()
Dim ConSht As Object
Set ConSht = ThisWorkbook.Sheets("Controls")
Dim showListIndex As Integer
showListIndex = MainDialog.ListBox_Workbook.ListIndex
If ConSht.Cells(showListIndex + 2, 3).FormulaR1C1 = "yes" Then
ConSht.Cells(showListIndex + 2, 3).FormulaR1C1 = "no"
Else
ConSht.Cells(showListIndex + 2, 3).FormulaR1C1 = "yes"
End If
Call FillWorkbookListbox
Call CreateFavoritesMenu
MainDialog.ListBox_Workbook.ListIndex = showListIndex
End Sub

Sub FillWorkbookListbox()
Dim ConSht As Object
Set ConSht = ThisWorkbook.Sheets("Controls")
dim lastRow as integer
lastRow = ConSht.Range("A16384").End(xlUp).Row
With MainDialog.ListBox_Workbook
.RowSource = "[" & ThisWorkbook.Name & "]" & "Controls!" &
"B2:C" & lastRow
.ColumnHeads = True
.ColumnCount = 2
.BoundColumn = 0
.ColumnWidths = "160;40"
End With
End Sub