Can you look at this code please

  • Hi,

    I have found a code but i cant get past a certain point.

    Here is the code.

    Can somebody please upload a file for me to look at as the line that fails every time for me is,

    With Sheet1.QueryTables(1).ResultRange

    Many thanks

  • Hello,

    A UserForm Initialize procedure ... cannot be floating around alone ... without an Excel file ...

    Feel free to attach your file

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just the bottom right corner...:)

  • Hi,

    Maybe i should advise first just in case im wrong & there is an easy solution to the existing working code in use ??

    When i search in textbox 1 the listbox is populated.

    I select a name from the listbox & the name in question is then selected on the worksheet.

    This works fine PROVIDING column C is sorted A-Z

    Lets say the worksheet is sorted in column B then i search on the userform,select from listbox etc then that name is selected on the worksheet.

    The problem i have is that looking at the listbox the name isnt correctly first in the list as i can scroll up through the listbox & there are many entries before the one shown.

    The reason why this one was shown as first position is because its the first of that type in column C

    This is the same result for any column BUT if column C is sorted A-Z then the list box shows the correct first entry.

    Does this make sense ?

    There might be a fix for the code supplied in use.

    The code i originaly started to play with was so i could collect the names in column C & sort on another sheet A-Z then load into listbox

  • Here is the file that i was playing with to get it working before i add it into my main sheet etc

    My goal is to copy information from the main worksheet.

    Create a new sheet.

    Paste the copied information.

    Sort A-Z

    Load this info on the userform.

    Delete new sheet.

    Now when i search the worksheet can be unsorted because we sorted the required information on the newly created sheet.

    Have a nice day