+ Reply to Thread
Results 1 to 7 of 7

User Form Command Button

Hybrid View

  1. #1
    Registered User
    Join Date
    01-14-2020
    Location
    Ohio
    MS-Off Ver
    Office 365
    Posts
    20

    User Form Command Button

    Attached is a small sample of my workbook. When the workbook is opened only the summary page is visible. There will be over 100 records. A person clicks the record it hyperlinks to the sheet. On that page I would like a command button for the User Form I created. I'm not sure if the problem is in the User Form coding or in the coding I was using for the command button. It should be as simple as userform1.show but it's not working. I need the user form to pop open and fill in the table on the right side. Any help would be greatly appreciated.

    Thank you
    Attached Files Attached Files
    Last edited by bb8371; 01-20-2020 at 03:43 PM. Reason: New Attachment

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,416

    Re: User Form Command Button

    .
    I created a second user form and it loads as expected.

    I suspect your workbook has become corrupted at some point, causing the issue/s you are experiencing now.
    My first action would be to delete the existing UserForm1 .... save the workbook and close it.

    Then after re-opening the workbook, create a new UserForm1 and try again.

  3. #3
    Registered User
    Join Date
    01-14-2020
    Location
    Ohio
    MS-Off Ver
    Office 365
    Posts
    20

    Re: User Form Command Button

    Then I'm doing something wrong with the User form. Is my coding wrong?

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: User Form Command Button

    Hi.
    Your combobox is name wrong in three instances in the initialisation code.
    cmbName should be cboName.
    Head your code 'Option Explicit' and run 'debug'.

  5. #5
    Registered User
    Join Date
    01-14-2020
    Location
    Ohio
    MS-Off Ver
    Office 365
    Posts
    20

    Re: User Form Command Button

    Thank you torachan. That worked. Would you mind looking at the updated version, please? I added the command button and the user box opens but when I click submit it doesn't do anything. I need it to input the data into the table on the right. Again.. Thank you so much for the fix. I was just certified in Excel but I still learning VBA coding.

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: User Form Command Button

    Hi.
    The reason nothing happened was you had named your 'sub' different to your 'command button'.
    A few early tips, we all develop different approaches, I can only say what works for me.
    First line type 'Option Explicit' this will force undeclared/wrongly named variables to show when you run 'debug'
    This can save many hours and headaches trying to work out why code does not run.
    When working with UserForm controls (e.g. command buttons)double click on the button, this will place the code ready for you to code.
    Similarly when transfering data (from form to sheet)/(sheet to form)use prefix 'Me' this will enable you to correctly id textboxes/combos etc.
    I am a big fan of 'Tables' used sensibly they can reduce code and maintenance.
    e.g. I have removed your hard coded 'employees' and placed them in a 'Table', all you now have to do is maintain the 'Table' NOT the code.
    Hope the alterations are helpful.
    happy coding.
    torachan.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-14-2020
    Location
    Ohio
    MS-Off Ver
    Office 365
    Posts
    20

    Re: User Form Command Button

    Thank you!!

+ 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. Disable Command Button in User form
    By Lclarke11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2015, 07:50 AM
  2. [SOLVED] Confirm Command button on user form using VBA
    By coach.32 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2013, 05:56 AM
  3. [SOLVED] Restricting command button action in a user form
    By coach.32 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 01:28 AM
  4. Want to add disply and edit command button in user form- :(
    By sinha.riteshabap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2013, 03:21 AM
  5. Help to creat user form with command button
    By sheree08 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2013, 04:10 PM
  6. User form RTE 13 when opening with a command button on a worksheet
    By iaingidley in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2011, 11:50 AM
  7. Command Button on User form for Printing
    By Anthony Slater in forum Excel General
    Replies: 2
    Last Post: 09-07-2005, 03: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