+ Reply to Thread
Results 1 to 9 of 9

Macro delete submit button when item selected from drop dowm list

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Macro delete submit button when item selected from drop dowm list

    Hi,

    I have an excel form with a command (submit) button that opens up Outlook when clicked. I am looking for a way to have this submit button disappear when the user selects a specific item in a drop down list to make sure they do not email the form when it is used for a promotion (Promotion would be selected in the drop down).

    Please let me know how/if this can be done.

    Thank you!

    V

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,002

    Re: Macro delete submit button when item selected from drop dowm list

    Yes, it can be done, but how depends on what you mean by "form" - is it a sheet that is set up in a certain way, or an actual userform? Is the dropdown list on a cell (data validation list), or is it a combobox or listbox on a form? In any case, the change event code for the cell, combobox, or listbox could be used to change the enabled property to True / False to enable / disable the commandbutton depending on the selected value. Post back with details if you need more help.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    02-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro delete submit button when item selected from drop dowm list

    Hi Bernie,

    Thank you for your reply.

    My "form" is an excel sheet that was set up a certain way, and the dropdown list is a Combobox (Form Control). When the user selects "promotion" from one of the dropdowns, I want the SUBMIT command button I created to disappear.

    I am new to coding and was able to figure out the coding needed to bring up outlook from the command button, but would like to know the coding I would need to perform this new action, and where this coding would be inserted (assign a macro to the specific dropdown where "promotion" is included, or include it in the macro assigned to the command button...).

    Thank you for your help, and please let me know if you need more details.

    Best,

    V

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,002

    Re: Macro delete submit button when item selected from drop dowm list

    Can you attach a (cleaned up if necessary) version of your file?

  5. #5
    Registered User
    Join Date
    02-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro delete submit button when item selected from drop dowm list

    Hi Bernie,

    Here is a cleaned up version of the form.

    Thank you,

    V
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,002

    Re: Macro delete submit button when item selected from drop dowm list

    I added this event code to the sheet "Action Reason" codemodule:
    Please Login or Register  to view this content.
    I left that sheet visible, but you can re-hide it. Here's the edited file:

    COPY Form.xlsm

    I wasn't sure if the worksheet "CRF_Oct 2012" will ever change name - if it can, then the code should use that sheet's codename instead of tab name:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro delete submit button when item selected from drop dowm list

    Hi Bernie,

    Thank you for your help! If I want to do this for other drop down's, would it be possible for you to post the steps you took to make this work? I am not sure where you posted these codes (where is the codemodule?).

    Thanks again!

    V

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,002

    Re: Macro delete submit button when item selected from drop dowm list

    The event to use depends on what you are doing. For this, because the linking of the listbox does not fire the change event, you need to use the calculate event of the worksheet where the value is being changed - the "Action Reason" sheet. It's codemodule contains the event code wrappers for it, and you get to the codemodule by double-clicking on the sheet name in the Project Explorer window of the VBE or by right-clicking the sheet tab and selecting "View Code"

    Further, you also need to make sure that some cell on the sheet uses the changed value in a calculation - in this case, you already had that, but it is possible that the calculate event will not fire either. So, workbook design is important...

  9. #9
    Registered User
    Join Date
    02-17-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro delete submit button when item selected from drop dowm list

    Hi Bernie,

    Thank you for all your help-it is very appreciated! My form now works!

    Best,

+ 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. Run macro when item from drop-down list is selected
    By barnett2000 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-09-2013, 12:52 PM
  2. Drop-down list button, that inserts new row below currently selected cell
    By hnuuma in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2013, 02:46 PM
  3. How to get index of selected item in drop down list?
    By nleahcim in forum Excel General
    Replies: 3
    Last Post: 08-08-2011, 02:08 PM
  4. Replies: 1
    Last Post: 05-18-2010, 07:36 PM
  5. Creating a Non-contiguous list in a drop-dowm dynamically.!
    By all4excel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-26-2008, 08:00 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