Displaying Column Titles in List Box

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question

    Regards to you all


    I am kindly seeking some enlightenment on the following scenario. The scenario is we have an Excel Sheet named Purchases. I have created a simple User form whose primary function is to facilitate the search of Purchase Receipt Nos using a text box and results are displayed in the list box. Basically what happens is that having entered the desired receipt no the user clicks the Search button and the results are displayed in the List box. The basic search procedure is working alright but column titles are not displayed though I have turned on the Column head property in my code. Is there any tweaking that I can apply to my code so that the column titles are displayed in the list box?


    DeBlackJackal

    Files

    • PURCHASES.xlsm

      (19.69 kB, downloaded 20 times, last: )
  • The ColumnHeads property only works if your listbox is linked to a range using the rowsource property, in which case the row above that range is used for the headers.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Not easily. You'd either need to add them as the first row of the listbox and prevent selection of that row, or add a second listbox above the first and use code to scroll them in sync. A range is a lot simpler for this.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why