Excel Combo box creation / deletion :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Combo box creation / deletion
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

wigwam
Board Regular


Joined: 01 Aug 2002
Posts: 42


Status: Offline

 Reply with quote  

Guys

Have used the code below to create two combo boxes on my sheet. However ... I cannot find a way to delete these prior to recreating ... data changes.

Can someone let me know how ... because of recreate I do not know there names.

thanks

Sub CreateDropDowns()
ActiveSheet.DropDowns.Add(1200, 20, 250, 22).Select

With Selection
.ListFillRange = "'Temp - Index'!$K$1:$K$8"
.LinkedCell = "'Temp - Index'!$K$12"
.DropDownLines = 8
.Display3DShading = True
.Caption = "Company Name : "
End With

ActiveSheet.DropDowns.Add(1200, 50, 250, 22).Select

With Selection
.ListFillRange = "'Temp - Index'!$L$1:$L$" & _
Worksheets("Temp - Index").Range("M1")
.LinkedCell = "'Temp - Index'!$K$14"
.DropDownLines = 8
.Display3DShading = True
.Caption = "Finance Type : "
.OnAction = "SelectionTaken"
End With

End Sub

Post Thu Dec 05, 2002 12:52 pm 
 View user's profile Send private message

Andrew Poulsom
MrExcel MVP


Joined: 22 Jul 2002
Posts: 8180

Flag: Uk

Status: Offline

 Reply with quote  

You can use Object variables to keep track of your DropDowns, like this:

code:

Dim Drp1 As Object
Dim Drp2 As Object

Sub CreateDropDowns()
    Set Drp1 = ActiveSheet.DropDowns.Add(1200, 20, 250, 22)
    With Drp1
        .ListFillRange = "'Temp - Index'!$K:$K"
        .LinkedCell = "'Temp - Index'!$K"
        .DropDownLines = 8
        .Display3DShading = True
        .Caption = "Company Name : "
    End With
    Set Drp2 = ActiveSheet.DropDowns.Add(1200, 50, 250, 22)
    With Drp2
        .ListFillRange = "'Temp - Index'!$L:$L$" & _
        Worksheets("Temp - Index").Range("M1")
        .LinkedCell = "'Temp - Index'!$K"
        .DropDownLines = 8
        .Display3DShading = True
        .Caption = "Finance Type : "
        .OnAction = "SelectionTaken"
    End With
End Sub

Sub RemoveDropDowns()
    Drp1.Delete
    Drp2.Delete
End Sub


Post Thu Dec 05, 2002 1:09 pm 
 View user's profile Send private message

wigwam
Board Regular


Joined: 01 Aug 2002
Posts: 42


Status: Offline

 Reply with quote  

Andrew .. thanks for that ... does make it better !!!

If I need to search for the combo's do you know a good way to look for them

cheers

Post Thu Dec 05, 2002 1:39 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.