+ Reply to Thread
Results 1 to 6 of 6

Macro to change drop down box selection

  1. #1
    Registered User
    Join Date
    09-18-2008
    Location
    London
    Posts
    6

    Macro to change drop down box selection

    Hello,

    I'd like to write a macro which changes the selection in a drop down menu (created using Data Validation\Settings\Allow\List) but I don't know how to do this.

    Normally when I'm stuck I tend to start recording a macro, do the function manually, and then stop and go in and check the code, however when you record a macro and then change the selection in a drop down box, it doesn't pick up that you have done anything.

    The reason I want to do this is that each selection in the drop down box causes data to change and this is linked into a graph. I want the macro to change the selection, then copy and paste the graph to another workbook, and then go to the next selection and so on.

    Any thoughts/help much appreciated.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon ksness

    ...and welcome to the forum!!
    Quote Originally Posted by ksness View Post
    I'd like to write a macro which changes the selection in a drop down menu (created using Data Validation\Settings\Allow\List) but I don't know how to do this.
    A data validation list is just a normal cell value, but with restrictions on the values that can be entered in that cell.

    Therefore just use the standard code to write values to cells (say your DV is in A1) :
    Range("A1").Value="New String"

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    09-18-2008
    Location
    London
    Posts
    6
    Thanks for the reply

    Sorry, I gave the wrong information

    The problem I have is its a drop down box created by right click and then "control" tab and then selecting the range, not the validation command I suggested in the initial post, sorry, so

    Range("cell").Value =

    doesn't work as its a box not a cell

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi ksness
    Quote Originally Posted by ksness View Post
    Sorry, I gave the wrong information
    The problem I have is its a drop down box created by right click and then "control" tab
    Range("cell").Value =
    doesn't work as its a box not a cell
    Try :
    Please Login or Register  to view this content.
    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    09-18-2008
    Location
    London
    Posts
    6
    Its a form control box, not active-X

    i have tried

    Please Login or Register  to view this content.
    But with no luck, gives me a runtime error 1004

    "Unable to set the value property of the DropDown Class"
    Last edited by VBA Noob; 09-24-2008 at 08:48 AM. Reason: Add code tags as per forum rules

  6. #6
    Registered User
    Join Date
    09-18-2008
    Location
    London
    Posts
    6
    Thanks for the help but I've finally cracked it

    Please Login or Register  to view this content.

+ 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] macro to blank combo box selection
    By elevdown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2008, 06:58 AM
  2. Macro on Drop Down Box Change
    By jmswebdesign in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-28-2007, 02:59 PM
  3. Drop Down Lists: change neighboring cell
    By MetalDwarf in forum Excel General
    Replies: 6
    Last Post: 03-14-2007, 12:12 PM
  4. Drop Down that can change?
    By darkjedi in forum Excel General
    Replies: 5
    Last Post: 12-19-2006, 11:13 AM
  5. Change populated cell names via macro
    By TJM in forum Excel General
    Replies: 2
    Last Post: 09-12-2006, 10:47 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