+ Reply to Thread
Results 1 to 6 of 6

Beginner User Form Help

  1. #1
    Registered User
    Join Date
    06-21-2022
    Location
    Sheffield
    MS-Off Ver
    365
    Posts
    4

    Beginner User Form Help

    Hello all, im new to VBA programming but im slowly getting there ive been struggling with an issues for a few days and online example code isnt helping me much.

    What i have is a user data form, the user enters all the values and clicks submit and these get added to a table in another worksheet, this is working fine although the code will need some tidying up. I have now added a search button which opens another userform, this for has a populated list of serials and a listbox. Id like the search function to collect all the rows from the table and show them to the user somewhow either populate a the list box. I will add all my code as it may offer clues.

    Main Form Code:

    Please Login or Register  to view this content.
    Search Form Code

    Please Login or Register  to view this content.


    Any help greatly appreciated.
    Attached Files Attached Files
    Last edited by jamesbarrett; 06-23-2022 at 04:50 PM.

  2. #2
    Forum Expert
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    3,208

    Re: Beginner User Form Help

    demo example attached - all data handling on one form
    declare your variables immediately after Option Explicit at head of code - variables are then available to each Sub (if declared in Sub they are restricted to that Sub)
    use default names for your form controls then you can loop through them and save many rows of code.
    to enter data first press 'Clear' then add data and press 'Add - the rest should be intuitive.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    06-21-2022
    Location
    Sheffield
    MS-Off Ver
    365
    Posts
    4
    Quote Originally Posted by torachan View Post
    demo example attached - all data handling on one form
    declare your variables immediately after Option Explicit at head of code - variables are then available to each Sub (if declared in Sub they are restricted to that Sub)
    use default names for your form controls then you can loop through them and save many rows of code.
    to enter data first press 'Clear' then add data and press 'Add - the rest should be intuitive.
    great thank you very much, i will look at the code and report back how i get on.

  4. #4
    Registered User
    Join Date
    06-21-2022
    Location
    Sheffield
    MS-Off Ver
    365
    Posts
    4

    Re: Beginner User Form Help

    Thanks for your help, i have the form saving data but in struggling to make the list box show data from the form, i either want to show all data matching user or device serial no. any more help would be appreciated. Attached is my current progress
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    3,208

    Re: Beginner User Form Help

    Look at your initialisation sub for the code below
    It utalises your table headers for the header bar above the listbox.
    The scroll bar added below the list box moves the header label and the listbox in sync on release of the drag with the mouse.
    The listbox (named Results) is set with 27 columns to match your data and the list is loaded with an array from your table datarange.
    When you read back to your sheet use the row index found from the listbox rather than searching the sheet (far quicker method when dealing with a large database)
    I have attached another simpler form demonstrating a double search (on name or title) this utalises an extra column as a rowcounter.
    This is because you will lose the listbox listindex as a method of direct linking to sheet row.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-21-2022
    Location
    Sheffield
    MS-Off Ver
    365
    Posts
    4

    Re: Beginner User Form Help

    Great, thanks again I really appreciate your help.

+ 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. VBA code to open a user form if the user form is located in an addin?
    By bresman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2019, 09:04 AM
  2. Upload inputs from a User Form repeatedly until the user clicks the red X on the Form
    By TheJimmyMcGill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2019, 05:46 PM
  3. How to help a beginner user?
    By Targaryen in forum The Water Cooler
    Replies: 10
    Last Post: 07-15-2017, 04:42 PM
  4. How to help a beginner user?
    By Targaryen in forum Excel General
    Replies: 7
    Last Post: 07-14-2017, 07:42 PM
  5. [SOLVED] VBA guide/template for a beginner, user form
    By Odowd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-28-2016, 05:43 PM
  6. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  7. VBA Beginner: Help with Checkboxes on created User Form
    By MarianneR in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-12-2005, 11:05 PM

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