+ Reply to Thread
Results 1 to 3 of 3

Troubleshoot Search feature in VBA userform

  1. #1
    Registered User
    Join Date
    01-26-2022
    Location
    Canada
    MS-Off Ver
    365
    Posts
    1

    Unhappy Troubleshoot Search feature in VBA userform

    Hello all,

    I have a workbook for tracking marketing leads which consists of 1 sheet of data (CRM). I created a userform that has a search feature to search for lead information and then populate the form so that a user to make appropriate edits. The form is on "Test - Data Entry Form" sheet. The "SearchData" sheet is needed in the back-end to store the search result.

    The problem: my search feature is not performing accurately. Specifically, I need to click "Search" command button twice for the list box to display my search result.

    Expected outcome: I'm hoping someone could troubleshoot this issue so that the form will display the search result the first time a user clicks "Search" command button

    I've attached the file in this thread with some dummy data for testing. I followed an online tutorial to create this form. If needed, I'll provide the link to that resource.

    Any suggestion would help. Thank you for your time!
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Troubleshoot Search feature in VBA userform

    I notice the code takes a long time to run.
    When you click the button a second time, you get the result after because the code finally finished running the first time.

    When you step through the code you will notice your lastrow variables are for the last row of the sheet, not the last filled row.

    You could select the data and copy it to a new sheet, delete the old sheet and rename the new sheet as the old sheet. Once saved, the wb will be a lot smaller and the lastRw variables should match the actual last filled row.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Troubleshoot Search feature in VBA userform

    Your Table(ListObject) has 1048560 blank rows
    This sample will give you an idea...I have deleted all your code...
    Open file...Click Button top of page...Then select Filter By and then start typing in Search Value
    The data will filter in listbox as required...No search button required...
    Some advice...Leave the controls to default names...this allows for easy reference and looping...
    It's crazy and pointless renaming them all...

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 01-31-2022 at 05:16 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-09-2020, 04:07 AM
  2. Combining my userform with a userform template - 'find' and 'amend' feature
    By excelconditional in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2017, 04:13 AM
  3. Using search feature followed by an if statement
    By Troyicus in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-12-2016, 03:03 PM
  4. Search Feature
    By Shazz in forum Excel General
    Replies: 3
    Last Post: 11-17-2009, 09:08 AM
  5. Search and open feature
    By TomBP in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-07-2006, 07:20 AM
  6. [SOLVED] Search Goto Feature
    By Bob in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-30-2006, 09:25 AM
  7. Search feature not too helpful
    By famdamly in forum Excel General
    Replies: 1
    Last Post: 02-26-2006, 09:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1