+ Reply to Thread
Results 1 to 5 of 5

VBA Userform to search Excel used as database

  1. #1
    Registered User
    Join Date
    06-30-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2010
    Posts
    3

    VBA Userform to search Excel used as database

    Hi Guys

    I am using excel as a database and I have created a userform that amongst other things searches a worksheet on button click. The problem I am encountering is that when I search, the search goes row by row, namely if the data being searched for is on row 3 in the worksheet, it first displays a "Not found" message for rows one and two and upon cancelling it moves to the next until it finds the entry. Is there a modification I can make so that the search goes smoothly, that is despite the row number if data is present it is immediately displayed without first showing a couple of "Not found" messages? PLEASE HELP!!! Below is my code for button click:




    Please Login or Register  to view this content.
    Last edited by alansidman; 07-01-2016 at 05:43 PM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: VBA Userform to search Excel used as database

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: VBA Userform to search Excel used as database

    Try removing or commenting out these lines of code

    Please Login or Register  to view this content.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA Userform to search Excel used as database

    Post example file with Userform and dummy data so your code can be rewrittin to suit your needs.
    Try this for starters.
    Please Login or Register  to view this content.
    Last edited by bakerman2; 07-01-2016 at 08:31 PM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Registered User
    Join Date
    06-30-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA Userform to search Excel used as database

    @alansidman: Thanks a span for adding my post to the forum. I will go through the rules. I also appreciate the links to the debugging resources you posted. These will prove to be invaluable even on future projects.

    @bakerman2: Thanks so much for the awesome idea to use the the with...end with statement. With that as a stepping stone I managed to work out the paradox. That was very helpful!!!

+ 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. Userform, Search, copy an paste data from a userform database to another sheet.
    By masro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2015, 02:42 PM
  2. Search Through Database And Display Results In Userform without showing database
    By nirvanarapeme in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2012, 05:18 PM
  3. Search through database and display results in userform
    By karthikcoep in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 05-24-2012, 05:08 AM
  4. Search through database and display results in userform
    By postmatt in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-31-2011, 10:04 AM
  5. Userform Search Database code
    By dcompagnone in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2010, 05:27 AM
  6. Database userform search data, go to row
    By dmanatee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2010, 09:06 AM
  7. userform to search excel database
    By ncaravela in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2010, 07:38 AM

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