+ Reply to Thread
Results 1 to 8 of 8

Macro runs from Data Validation Drop Down List Selection

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    45

    Macro runs from Data Validation Drop Down List Selection

    Hi all,

    First time poster - apologies if any forum rules get broken.

    Problem -

    I am trying to setup a macro to run off a selection made from a drop down list made via data validation.

    The selections are:

    Jan-13
    Feb-13
    Mar-13
    Apr-13
    May-13
    Jun-13
    Jul-13
    Aug-13
    Sep-13
    Oct-13
    Nov-13
    Dec-13

    The following code i added to the sheets private code is:

    Please Login or Register  to view this content.

    The issue currently is that i select the specific month i want and nothing happens. The call macros are simple copy and paste code, example is below:

    Please Login or Register  to view this content.

    Any help is appreciated

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro runs from Data Validation Drop Down List Selection

    What is the actual value of the cell, it might have turned it into a date (e.g. 01/01/2013 instead of Jan-13). in which case you would need to replace:
    Case "Jan-13":
    with
    Case "01/01/2013":

    Also, do you want this to run when you change anything or just the data validation cell? it might be worth including something like:
    if target.address = "$C$6" then
    'Code
    end if

    Edit: you might also want to have application.enableevents turned off whilst you run this macro otherwise you could end up in an infinite loop, depending what the macros you are calling are doing.

  3. #3
    Registered User
    Join Date
    05-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro runs from Data Validation Drop Down List Selection

    I've got the correct format, so the values are eg "Jan-13" etc.

    I don't want anything to run when the data is being changed, this macro should only run when it has been selected from the drop down list.

    Would i need to put that Application.Enableevents = False in the separate macro code that i call, or the private sub code?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro runs from Data Validation Drop Down List Selection

    I'd do it like this:
    Please Login or Register  to view this content.
    From what I can see the code should work if the values are in the form "Jan-13", can you upload an example workbook with the code in so I can check it with the actual data you are using? The other thing I guess is that the data validation is in cell C6?

  5. #5
    Registered User
    Join Date
    05-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro runs from Data Validation Drop Down List Selection

    The code has changed slightly now...

    Please Login or Register  to view this content.
    Still getting nothing when each option is selected.

    I've attached the example workbook as well
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro runs from Data Validation Drop Down List Selection

    That works fine for me... Probably daft suggestion but only other thing I can think of is your enableevents has been set to false while you have been changing things...

  7. #7
    Registered User
    Join Date
    05-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro runs from Data Validation Drop Down List Selection

    This is rather annoying.

    I've gone to View>Immediate Window

    and set Application.EnableEvents=True

    Still, nothing is working

  8. #8
    Registered User
    Join Date
    05-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro runs from Data Validation Drop Down List Selection

    It works, i rebooted excel and everything seems to be working perfectly now....funny!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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