+ Reply to Thread
Results 1 to 13 of 13

Delete combo boxes

  1. #1
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Delete combo boxes

    How can multiple combo boxes be deleted in an Excel sheet using code.
    These are the type Combo Box (Form Control) inserted from the Visual Basic Developer tab.
    The name is Drop Down #.
    Below code works only if you know the name.

    Please Login or Register  to view this content.
    Capture.PNG

  2. #2
    Forum Contributor
    Join Date
    12-08-2020
    Location
    South Korea
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Delete combo boxes

    Try This
    Please Login or Register  to view this content.
    Caring environment and nature. caring you.

  3. #3
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Re: Delete combo boxes

    Hi, thanks, this was correct.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Delete combo boxes

    You can also
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Re: Delete combo boxes

    OK thanks I will try this as well.

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Delete combo boxes

    I want to point out the danger of using loops
    Please Login or Register  to view this content.
    Let's start from the beginning, though.
    Let's assume that in the sheet, in addition to the DropDown controls we inserted ourselves, there are also cells with drop-down lists (from data validation). The control that develops the list is sometimes classified (*) to the xlDropDown type when we search the Shapes collection. For all validation lists in active sheet, there is only one control whose position changes depending on the data validation cell that is currently active. As you might guess, the control is removed in the loop quoted above. Fortunately, when the file is reopened, the control is rebuilt.
    However, this control is not part of the DropDowns collection ( by default hidden since version 2007). At least that's what the tests show.

    * I purposely used the phrase "sometimes classified", because from testing it seems that it varies with this. Once it is, and other times it is not so classified. I have already encountered the ambiguity of the classification of graphic objects in the past with the Pictures collection. But I never learned the reason for this behavior.

    Artik

  7. #7
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Re: Delete combo boxes

    OK thanks for letting me know.
    How could it be done so it only loops through the relevant objects mentioned in the original post?

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Delete combo boxes

    Did you try the code I posted?

    All you need is that one line.

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Delete combo boxes

    lb_33, if you want to remove all DropDown controls (I'm thinking of the "real" ones), it doesn't make sense to do it in a loop. Use jindon's code.
    On the other hand, if you want to delete or modify only specific controls, then use a loop across the DropDowns collection, not across the Shapes collection.

    Artik

  10. #10
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Re: Delete combo boxes

    OK now I understand that Jindon's code is suitable.

    But I couldn't get a loop to work though.
    If possible please revise and compare to a name like "*Drop Down To Del*", so it will delete only these drop downs. I should have mentioned that at the start.

    Please Login or Register  to view this content.
    Last edited by lb_33; 08-28-2022 at 10:40 AM.

  11. #11
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Delete combo boxes

    Please Login or Register  to view this content.
    Artik
    Last edited by Artik; 08-28-2022 at 10:54 AM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Delete combo boxes

    Then
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    01-22-2022
    Location
    UK
    MS-Off Ver
    365
    Posts
    129

    Re: Delete combo boxes

    Great, thanks to both as both macros work.

+ 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. Suddenly unable to use text boxes/combo boxes on my computer
    By eawesley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2020, 10:28 AM
  2. How to link combo boxes and list boxes in VBA using active x controls
    By LaSouth1776 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2020, 12:46 PM
  3. [SOLVED] Delete a row based on value of 2 combo boxes (2 columns)
    By kevo1588 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2017, 11:44 AM
  4. [SOLVED] Help with code for userform text boxes, combo boxes and excel
    By innerise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 09:07 AM
  5. populating list boxes and combo boxes in a user form.
    By ahceinaej in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2014, 11:54 AM
  6. assigning data to lists boxes and combo boxes in userforms
    By weston.roberts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2011, 03:11 AM
  7. assigning data to lists boxes and combo boxes in userforms
    By weston.roberts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2011, 08:46 PM

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