List box deselect
That's perfect! Thank you
"Dave Peterson" wrote:
Is this a listbox from the control toolbox toolbar that's on a worksheet?
If yes, then you have code associated with that listbox that updates that range
-- and it sounds like you have trouble with that code.
I put a listbox from that control toolbox toolbar on a worksheet and wanted to
put all the values for the indexes in B1, B2, .... for each item selected.
This is the code I used in behind that listbox:
Option Explicit
Private Sub ListBox1_Change()
Dim iCtr As Long
Dim DestCell As Range
Dim HowMany As Long
HowMany = Me.ListBox1.ListCount
Set DestCell = Me.Range("B1")
DestCell.Resize(HowMany).ClearContents
With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = iCtr '+1
'get the value, too???
DestCell.Offset(0, 1).Value = .List(iCtr)
'get ready for next item
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With
End Sub
comparini3000 wrote:
I have a list box (fmMultiSelectExtended) to display selections (by numeric
code) in a range of cells. However, when I deselect an option, the
corresponding number does not delete itself from the output list. The reason
why this is so important is because I have a lookup function setup in another
range that tells the user the choices they have made (this is because there
are many choices and it would take too long to scroll and look back at
everything). How can I update the list box output range to reflect
deselection?
Thank you,
comparini3000
--
Dave Peterson
|