Consulting

Results 1 to 7 of 7

Thread: cannot get Listbox column count property

  1. #1

    Unhappy cannot get Listbox column count property

    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 !

    listbox problem.jpg

    i really appreciate your help

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You only have one column. Use List instead of Column.
    Be as you wish to seem

  3. #3
    Quote Originally Posted by Aflatoon View Post
    You only have one column. Use List instead of Column.
    Thanks for replay .. Can you explain more? i did not get it.

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Me.Listbox1.List(1)
    and not
    Me.Listbox1.Column(1)
    Be as you wish to seem

  5. #5
    Thank you soo much bro.
    it works fine.

  6. #6
    Quote Originally Posted by Aflatoon View Post
    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 ?

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    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.
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •