ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   listbox (https://www.excelbanter.com/excel-programming/281274-listbox.html)

sal

listbox
 
Hi a have list box with this code in it.
Private Sub ListBox1_Click()
ActiveCell.Value = ListBox1.Value
strStartDir = ThisWorkbook.Path
GraphicFile = strStartDir & "\150\" & ActiveCell.Value & "a.jpg"
Image1.Picture = LoadPicture(GraphicFile)

ActiveCell.Value = ListBox1.Value
strStartDir = ThisWorkbook.Path
GraphicFile = strStartDir & "\150\" & ActiveCell.Value & "b.jpg"
Image2.Picture = LoadPicture(GraphicFile)
End Sub

everything works fine except when in the list box, if two items get
clicked on or highlighted at the same time by accident then I get a
runtime error 53. How can I force only one item to be selected. I have
multiselect set to single from the list box options.

Tom Ogilvy

listbox
 
Set the multiselect propery to false

--
Regards,
Tom Ogilvy

sal wrote in message
om...
Hi a have list box with this code in it.
Private Sub ListBox1_Click()
ActiveCell.Value = ListBox1.Value
strStartDir = ThisWorkbook.Path
GraphicFile = strStartDir & "\150\" & ActiveCell.Value & "a.jpg"
Image1.Picture = LoadPicture(GraphicFile)

ActiveCell.Value = ListBox1.Value
strStartDir = ThisWorkbook.Path
GraphicFile = strStartDir & "\150\" & ActiveCell.Value & "b.jpg"
Image2.Picture = LoadPicture(GraphicFile)
End Sub

everything works fine except when in the list box, if two items get
clicked on or highlighted at the same time by accident then I get a
runtime error 53. How can I force only one item to be selected. I have
multiselect set to single from the list box options.





All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com