How to use listbox double click in order to put the value into 10 different labels in form?

ping0775

New Member
Joined
Jul 18, 2022
Messages
40
Office Version
  1. 2007
Platform
  1. Windows
How to use listbox double click in order to put the value into 10 different labels in form?
i been trying so hard
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

IssueDOCumSalesInvoiceForm.ItemCode1.Caption = Me.ListBox1.Text
IssueDOCumSalesInvoiceForm.ItemCode2.Caption
IssueDOCumSalesInvoiceForm.ItemCode3.Caption..to 10 etc

i should transfer the data to sheet first by using
IRow = Sheet6.Range("a" & Rows.Count).End(xlUp).Row + 1 ?
then from there put cell value to label?
or any alternative way to solve?
 
You need to help by supply more details.
Yea correct, ist possible?
I have 2 forms
Form A
this form contain ten lables.
Form B
this form contain one listbox loading the productlist.

one i double click the listbox in Form B
the item will be show into Form A Label box in order mode
one double click , the clicked item will be shown in Label1
another double, the second clicked item will be shown in Label2
and so on to labels 10
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Or one dbl click to copy all over?
VBA Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
Dim IsLoaded As Boolean
Dim frm As Object

For Each frm In VBA.UserForms
     If frm.Name = "UserForm1" Then
          IsLoaded = True
          Exit For
     End If
Next

If IsLoaded Then
     For i = 1 To 10
          UserForm1.Controls("Label" & i).Caption = Me.ListBox1.List(i - 1)
     Next
End If

End Sub
Change the variables (e.g. name of userform1) to your object names. Form name is case sensitive.
 
Upvote 0
Or one dbl click to copy all over?
VBA Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
Dim IsLoaded As Boolean
Dim frm As Object

For Each frm In VBA.UserForms
     If frm.Name = "UserForm1" Then
          IsLoaded = True
          Exit For
     End If
Next

If IsLoaded Then
     For i = 1 To 10
          UserForm1.Controls("Label" & i).Caption = Me.ListBox1.List(i - 1)
     Next
End If

End Sub
Change the variables (e.g. name of userform1) to your object names. Form name is case sensitive.
can you assist me? it still cant solve
 

Attachments

  • hihi.jpg
    hihi.jpg
    193.5 KB · Views: 7
Upvote 0
I don't see any evidence of labels in that picture that are named ItemCode1, ItemCode2, ... ItemCode10.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top