I found the problem. I don't know how to erase this post.
I found the problem. I don't know how to erase this post.
Last edited by Monikbor; 10-14-2021 at 03:05 PM.
I don't understand a couple of things in your code.
I is never set, so this line of code will refer to Listbox1.List(0), the first element. Do you mean to put a loop around this?![]()
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim sh As Worksheet Dim SelectedRGA As Range, R As Long, I as Long Dim SearchObj As String If ListBox1.Selected(I) = True Then
Do not GoTo or Select cells just to reference them.
Here is my best guess, but it would help to have your file. See yellow banner at the top.
![]()
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) Dim sh As Worksheet Dim SelectedRGA As Range, R As Long, I As Long Dim SearchObj As String For I = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(I) Then SearchObj = Me.ListBox1.List(I, 0) With sh.Range("E:E") SelectedRGA = .Find(what:=SearchObj) If Not SelectedRGA Is Nothing Then R = SelectedRGA.Row Me.Labelrequestor.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 2).Value Me.Labeldate.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 3).Value Me.LabelRGANo.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 5).Value Me.Labelproduct.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 15).Value Me.LabelIFS.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 16).Value Me.Labelramassage.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 17).Value Me.Labelwarehouse.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 18).Value Me.Labelnature.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 19).Value Me.LabelQty.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 21).Value Me.LabelContainer.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 22).Value Me.LabelDescription.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 20).Value Me.Labelclient.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 27).Value Me.LabelDescription.Caption = ThisWorkbook.Sheets("2021-CSM").Cells(R, 20).Value End If End With End If Next I End Sub
Jeff
| | |·| |·| |·| |·| | |:| | |·| |·|
Read the rules
Use code tags to [code]enclose your code![/code]
Hi 6StringJazzer
Thanks for your answer.
I finally could make it work, but your answer was exactly what I needed to solve the next problem I found.
Effectively, it only worked for the first line!
Thanks again!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks