+ Reply to Thread
Results 1 to 8 of 8

VBA code for creating dependent drop down list

  1. #1
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    VBA code for creating dependent drop down list

    I would like to create two drop lists, one dependent on the other. For example there will be two drop down list STATE and CITY. When I select a value from drop down list STATE, correspondingly the values of CITY drop down list must change.
    It would be nice if you could embed the code in XLS and attach it to your post rather than posting the code.
    I am using MS Office 2003

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA code for creating dependent drop down list

    Do you know you can do this without VBA?

    There's some info here: http://www.contextures.com/xldataval02.html

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: VBA code for creating dependent drop down list

    but I am looking for VBA...perhaps some SQL statement

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA code for creating dependent drop down list

    Just thought I should point out that it can be done without it.

    Have a look here: http://www.xtremevbtalk.com/showpost...22&postcount=5

    Dom

  5. #5
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: VBA code for creating dependent drop down list

    Follow the link below to find the related post...

    http://www.excelforum.com/excel-prog...ist-boxes.html

    Its easy to follow and helps alot...


    Small suggestion here, if u want to add small data use below code..

    Please Login or Register  to view this content.
    otherwise, if u want to add data from the spreadsheet range use below for loop to add data to the combo box
    Please Login or Register  to view this content.

    Regards,

    SK
    Last edited by skonduru; 05-25-2010 at 10:25 AM.

  6. #6
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: VBA code for creating dependent drop down list

    Quote Originally Posted by Domski View Post
    Do you know you can do this without VBA?

    There's some info here: http://www.contextures.com/xldataval02.html

    Dom
    Hi, thanks. I have two problems with this. Firstly, is that I am unable to modify the named list, or delete it. Secondly, the values don't get resetted to blank if i change my parent value in drop down list. For exampl I have selected FRUIT in my parent dropdown and APPLE in my dependent dropdown. Now if I change FRUIT to VEGETABLE, the dependant cell still shows APPLE. I want it to be resetted to blank.

    Please could you help

  7. #7
    Registered User
    Join Date
    06-25-2009
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: VBA code for creating dependent drop down list

    Quote Originally Posted by Domski View Post
    Do you know you can do this without VBA?

    There's some info here: http://www.contextures.com/xldataval02.html

    Dom
    Hi, thanks. I have two problems with this. Firstly, is that I am unable to modify the named list, or delete it. Secondly, the values don't get resetted to blank if i change my parent value in drop down list. For exampl I have selected FRUIT in my parent dropdown and APPLE in my dependent dropdown. Now if I change FRUIT to VEGETABLE, the dependant cell still shows APPLE. I want it to be resetted to blank.

    Please could you help

  8. #8
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: VBA code for creating dependent drop down list

    Quote Originally Posted by singhabhijitkumar View Post
    Hi, thanks. I have two problems with this. Firstly, is that I am unable to modify the named list, or delete it. Secondly, the values don't get resetted to blank if i change my parent value in drop down list. For exampl I have selected FRUIT in my parent dropdown and APPLE in my dependent dropdown. Now if I change FRUIT to VEGETABLE, the dependant cell still shows APPLE. I want it to be resetted to blank.

    Please could you help
    use
    Please Login or Register  to view this content.
    Hope this helps...
    Last edited by skonduru; 05-26-2010 at 08:31 AM.

  9. #9
    Registered User
    Join Date
    09-26-2008
    Location
    India
    Posts
    1

    Re: VBA code for creating dependent drop down list

    Quote Originally Posted by Domski View Post
    Just thought I should point out that it can be done without it.

    Have a look here: http://www.xtremevbtalk.com/showpost...22&postcount=5

    Dom
    Thanks Nice example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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