+ Reply to Thread
Results 1 to 7 of 7

Delete command button from UserForm Frame

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    Shropshire
    MS-Off Ver
    Excel 2010
    Posts
    18

    Delete command button from UserForm Frame

    Hi, the following code adds a new command button to a excel user form frame (thanks to help from the forum).

    Please Login or Register  to view this content.
    Now comes the problem of deleting an account.

    The existing accounts are listed in a list box, account for deletion is selected as per code below:

    Please Login or Register  to view this content.
    The code below should delete the required account but I can not get it to work.

    Please Login or Register  to view this content.
    At line: Set DelFrameBtn = .Controls(mpfBankAccounts).Controls.Remove("Forms.CommandButton.1") I get compile error: Invalid or Unqualified reference.

    I would appreciate any help on this, thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Delete command button from UserForm Frame

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Delete command button from UserForm Frame

    Move the Set DelFrameBtn = .Controls... line down below the With MyUserForm line. The .Controls refers to a userform, so it should be within your With - End With code block.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    02-21-2014
    Location
    Shropshire
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Delete command button from UserForm Frame

    Thanks Guys, you pointed me in the right direction. The following code did the job:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Delete command button from UserForm Frame

    You're welcome.

    I didn't test this, but something like this may work as well.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-21-2014
    Location
    Shropshire
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Delete command button from UserForm Frame

    It seems I was a little premiture in thinking all was well.

    When I delete an account I can pickup "SundryAccount1" with a variable generated using a listbox, I am Having trouble seting a variable to the frame name.

    the code I am Using is:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51
    Quote Originally Posted by nicksyplonk View Post
    It seems I was a little premiture in thinking all was well.

    When I delete an account I can pickup "SundryAccount1" with a variable generated using a listbox, I am Having trouble seting a variable to the frame name.

    the code I am Using is:
    Please Login or Register  to view this content.
    I only want to ask the question: When This workbook is ment, and the Userform object is known, why not use
    Please Login or Register  to view this content.
    I don't see the point why the VbProject is required.
    Maybe this gives an idea.
    Last edited by Warbe; 07-09-2020 at 04:08 PM.

+ 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] Run Command Prompt Icacls code in VBA Command Button on Userform
    By luismalave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2015, 11:40 PM
  2. [SOLVED] UserForm Frame Command Button
    By nicksyplonk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2015, 11:28 AM
  3. [SOLVED] Looping through controls by frame on userform (frame within a frame)
    By njs27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2015, 10:21 AM
  4. [SOLVED] Userform: Code for DELETE on a command button
    By Gal403 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2014, 01:28 AM
  5. [SOLVED] Pull a Hidden frame when clicked command button.
    By venkcris in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-02-2014, 08:52 PM
  6. Userform Minimize Button Code Blocking Focus for First TextBox in Frame
    By excelforumkeys in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2014, 12:57 PM
  7. Userform Command Button to open new userform
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2010, 12:02 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