PDA

View Full Version : cannot get Listbox column count property



shi6oonz
06-18-2018, 06:34 AM
Hello All

i am facing a problem and i wish from you to help with it

The Problem :

i have a userform with listbox1 & CommandButton1 and i am using the listbox1 to select file name from Sheet5 > Rowsource "d1:d20" and to open it as pdf

i used this code


If Me.ListBox1.Column(0) = "cie_plant_result_list" Then
ThisWorkbook.FollowHyperlink "C:\Result\cie_plant_result_list.pdf." and it work perfect !

but i am trying to get second file to Listbox1.column(1) for example :


If Me.ListBox1.Column(1) = "edc_plant_result_list" Then
ThisWorkbook.FollowHyperlink "C:\Result\edc_plant_result_list.pdf."
End If

after press the commandbutton1 this error display !

22446

i really appreciate your help

Aflatoon
06-18-2018, 07:19 AM
You only have one column. Use List instead of Column.

shi6oonz
06-18-2018, 07:45 AM
You only have one column. Use List instead of Column.

Thanks for replay .. Can you explain more? i did not get it.

Aflatoon
06-18-2018, 07:48 AM
Me.Listbox1.List(1)
and not

Me.Listbox1.Column(1)

shi6oonz
06-18-2018, 07:54 AM
Thank you soo much bro.
it works fine. :yes:thumb

shi6oonz
06-18-2018, 10:19 AM
Me.Listbox1.List(1)
and not

Me.Listbox1.Column(1)

Dear i used your code but i notice that the listbox1.list(2) opening the file of listbox1.list(1) and listbox1.list(0)
what i need to do is ... listbox1.list(0) FollowHyperlink different than Hyperlink of listbox1.list(1) or listbox1.list(2)

... any idea ?:crying:

Aflatoon
06-19-2018, 02:25 AM
Your code pays no attention to what is selected. It simply compares the contents of the listbox, selected or not, with various values. I'm guessing that that was not what you intended. You should probably be looking at the listbox1.value or using listbox1.list(listbox1.listindex) to get the selected item.