+ Reply to Thread
Results 1 to 8 of 8

Macro to select Validation List & allowing Worksheet_change to operate

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question Macro to select Validation List & allowing Worksheet_change to operate

    Hi Guys,

    I was wondering whether it was possible to have a macro run, select the first option from a validation list - this starts another macro in worksheet_Change.
    When Worksheet_Change macro finishes then select the next option from the validation list. which will in turn cause worksheet_Change to run.
    etc etc for all possible options in the validation list.

    When the validation list changes this causes rows to hide/show on all other worksheets in the WB.
    My goal is to create a macro that will select the first option from this validation list, let the Worksheet_Change macro run and hide/show the rows, then export the workbook.
    Then repeat this for all values found in the validation list

    regards

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,489

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    Simple answer: yes, it's possible. You just loop through the entries in the DV list, dropping each value into the cell, taking whatever action is required and doing a SaveCopyAs.

    Detailed answer: you'll need to provide a lot more detail including a sample workbook, bullet points of the action(s) required, any constraints, etc.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    WB attached. ive supplied some notes / explanations in this attached WB

    thanks a heap
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    CYCLE THROUGH DV OPTIONS
    Here's a basic macro for cycling through all the Data Validation options in a certain cell. The sample then prints out the workbook, but you can replace that line of code with whatever action you prefer, this should give you the basics.

    Cycle Through Data Validation Options
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    Thank you JBeaucaire!

    This is crashing on the line
    Please Login or Register  to view this content.
    an example of myDVList is 'Red,Blue,Green Trees'
    not sure why this may be causing the issue

    Just a quick note (and please see the attached WB to confirm this) I am automatically generating the DVList using the worksheet_activate function.
    Im not sure if this would throw of your supplied code because of this?

    thanks again!
    Last edited by jordan2322; 07-16-2012 at 06:58 PM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    Ah, this method assumes the DV list is a range of cells, not a builtin list. Hmm...

  7. #7
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    Is there any other methods to this if its a 'built in list' ?

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to select Validation List & allowing Worksheet_change to operate

    Ok, I've updated the published page to add in that capability into the basic macro.

+ 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