+ Reply to Thread
Results 1 to 9 of 9

Userform Command Buttons needing certain coding

  1. #1
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Userform Command Buttons needing certain coding

    Hi,

    I was wondering if someone could help me please?

    I'm just trying to setup a new userform (MES_ASA) but I am struggling with codes for 2 of the command buttons.

    What I've managed to do so far is when the operator selects either Azera, L, M and N in column E the userform appears and if they press "Yes" the userform closes.

    What I would like to happen with the 2 commands I'm struggling with is:

    Command button 2 "No" - I would like when pressed, to clear the contents of cells E and K and the exit the userform.

    Command Button 3 "Unavailable" - I would like when pressed, is to enter the words "MES_ASA Unavailable" in column L and then exit the userform.

    Any help would be much appreciated.

    Kind Regards

    Dan
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform Command Buttons needing certain coding

    It's a little pointless attaching a workbook with a password protected project...

    Regardless, while you have a sub to open the userform
    Please Login or Register  to view this content.
    please explain how/when that is executed and which row is to be updated.

  3. #3
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Userform Command Buttons needing certain coding

    Hi cytop,

    Sorry I thought I'd removed the password. The password is "motorola"

    I've been searching the internet for answers about the coding I require and I put that in on my first search thinking I needed it. I realise now its not needed.

    Kind Regards
    Dan

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform Command Buttons needing certain coding

    What you need it to get a result from the user and update accordingly...

    Skeleton code for the userform as below
    Please Login or Register  to view this content.
    Note the userform is only hidden when a button is clicked - it needs to be still loaded so the calling procedure can check which button was clicked.. The calling procedure (or at least the part dealing with Col E) changes like so:
    Please Login or Register  to view this content.
    Your logic to check the actual input to the cells not tested...

  5. #5
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Userform Command Buttons needing certain coding

    Hi cytop,

    that's worked brilliantly, thank you so much.

    Kind Regards
    Dan

  6. #6
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Userform Command Buttons needing certain coding

    Hi cytop,

    I was wondering if you could help a little more with your/my coding please?

    Everything you've done is perfect but what I've realised is if an operator selects the "MES_ASA Unavailable" button by mistake and then deletes what's in cell E via the keyboard, it leaves "MES_ASA Unavailable" in cell L.

    Is there some coding that can be added so if cell E is deleted via the keyboard it also deletes whats in cell L?

    Thanks again for your help.

    Kind Regards

    Dan

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform Command Buttons needing certain coding

    Just add an 'ElseIF' in the Worksheet_Change event handler checking if cel is blank and clearing Col L on the same row if it is...

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: Userform Command Buttons needing certain coding

    perfect again cytop, thank you.

  9. #9
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform Command Buttons needing certain coding

    Just as a minor update, move the lines Disabling & Enabling Events outside the For ... Next loop.

    Not that it matters, but clearing the cell in column L will cause the Change event to fire again - there's nothing there that will execute for a change in L but there's no point executing code needlessly.

+ 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. [SOLVED] count all command buttons on the userform
    By serenitylai in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-30-2017, 09:58 PM
  2. Align Command Buttons On UserForm
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2014, 01:28 PM
  3. Coding Search and Update Command Button in an UserForm
    By sottojeromey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2013, 06:39 AM
  4. [SOLVED] Positioning multiple command buttons on a userform using VBA
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2012, 04:13 PM
  5. filter data by userform command buttons
    By dude19 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2011, 04:55 AM
  6. Naming command buttons on a UserForm
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2006, 11:47 AM
  7. adding userform command buttons
    By borg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2006, 12:15 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