ListBox1.ListIndex Property

Gilberto Fernandes

New Member
Joined
Jun 16, 2015
Messages
5
Main Form.jpg

Hi everyone, my name is Gil, I have this screen (Userform) with 3 Listbox (The third has been cut) that show me what is being operated on the 3 machines.
I am trying to implement a routine where I click on one of the operation and open a new Userform showing the operations Information in separate TextBoxs to for example update the operation or delete it.
For that I am trying to use the following command to capture the information:

Sub ListBoxM1_Click()

machine.Value = ListBoxM1.List(ListBoxM1.ListIndex, 0)
Pallet.Value = ListBoxM1.List(ListBoxM1.ListIndex, 1)
Dayvalue.Value = ListBoxM1.List(ListBoxM1.ListIndex, 2)
Nightvalue.Value = ListBoxM1.List(ListBoxM1.ListIndex, 3)
Unatvalue.Value = ListBoxM1.List(ListBoxM1.ListIndex, 4)

End Sub

But I am getting the error showing in the pic “Object required”. Could someone help me with that?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Have you checked all the control names?
 
Upvote 0
Have you checked all the control names?
Sorry Norie, I am learning VBA by myself and I am not sure about what you mean. I am getting the values for each operation from a range of cells on a spreadsheet. As far as I know, I am creating a new variable when I am doing the command "machine.Value = ListBoxM1.List(ListBoxM1.ListIndex, 0)". The new variable is called "machine", am I right? I do not understand what you mean by Control Names.
 
Upvote 0
If machine, Pallet etc. are variables then you don't use .Value.
VBA Code:
Sub ListBoxM1_Click()

machine= ListBoxM1.List(ListBoxM1.ListIndex, 0)
Pallet = ListBoxM1.List(ListBoxM1.ListIndex, 1)
Dayvalue = ListBoxM1.List(ListBoxM1.ListIndex, 2)
Nightvalue = ListBoxM1.List(ListBoxM1.ListIndex, 3)
Unatvalue = ListBoxM1.List(ListBoxM1.ListIndex, 4)

End Sub
 
Upvote 0
Yes, Perfect. Thank you Norie. It worked Perfectly.
I need to find a course that teaches these small details. For example, I would like to know why should I not use ".value" with variables, and anothers small details that makes a huge difference in the end. Could you suggest me a book to buy? Or a course? I would appreciate..
Thank you again.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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