ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a listbox effectivly (https://www.excelbanter.com/excel-programming/290474-using-listbox-effectivly.html)

Robert Couchman[_4_]

Using a listbox effectivly
 
Hello,

its me again.

good news, all my input stuff works, my find stuff works,
but now...

can anyone please help, i find records for my list box and
i wish to double click on an entry and open the
appropriate information from columns 2,3,4 and 6.

Thank you,

Robert Couchman

Colo[_93_]

Using a listbox effectivly
 
Hello Robert,

You can use DblClick event on the Listbox and you can get which valu
was doubleclicked with the code below.


Code
-------------------

ListBox1.List(ListBox1.ListIndex)

-------------------


Using this value, please try to find the value in the worksheet.
If you can find the range, you can get the ROW with rows property.
Next you can get appropriate information.


Code
-------------------

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Seq
Dim rngFound As Range
Seq = ListBox1.List(ListBox1.ListIndex)
Set rngFound = Columns(2).Find(Seq)
If Not rngFound Is Nothing Then
MsgBox Cells(rngFound.Row, 2).Value
MsgBox Cells(rngFound.Row, 3).Value
MsgBox Cells(rngFound.Row, 4).Value
MsgBox Cells(rngFound.Row, 6).Value
End If
End Sub

-------------------


--
Message posted from http://www.ExcelForum.com


Robert Couchman[_4_]

Using a listbox effectivly
 
Thank you for your code, it works very well if there is
only one piece of data specified.

only problem is...

i have my data laid out as follows

listbox1
------------------------------
foundresult + " " + foundresult.offset(0, 2)

so when i look for the data in column 2 it would not find
it due to the column 4 data being added to the list
display.

can anyone help?

either by explaining how to place the found result data
into seperate columns in the list then displaying the
record where the two columns results match on the same row.

or by explaining how to use the columns4 + " " + columns5
as .find result!!

Thank you,

Robert Couchman


All times are GMT +1. The time now is 01:28 PM.

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