Macro/vba that runs on certain sheets selected from a list of sheet names

  • Hi!

    Please help me with a code that runs a macro on certain sheets. I have a list of sheetnames in my first sheet and want that when I run this vba code/macro it runs on each of the sheets I have selected/highlighted out of the sheetnames I have listed on that first sheet.

    The code I currently am using I have put into each sheet but that has become to cumbersome.
    Here is the code I am using.

    [Blocked Image:]

    1. Private Sub Worksheet_Calculate()
    2. Application.EnableEvents = False
    3. Range("D4").GoalSeek Goal:=0, ChangingCell:=Range("C13")
    4. Application.EnableEvents = True
    5. End

    Is this possible?

    All help is appreciated. Thanks!


  • Hello and Welcome to the Forum :)

    Please attach your workbook ... it would make everything much easier ... for everybody ...;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just the bottom right corner...:)

  • Hi Carim,

    Thanks for the help.

    This code Goalseeks on all the sheets in the list.

    I would like to be able to highlight/select with the cursor certain sheetnames from the sheetnames list on the master sheet for the code to run on only those specific sheets and not the others.

    For example:

    I would select the cells in the list of sheet names except three if at one point I wanted all sheets in the list except sheets Brian, George, and Jeffery to be goalseeked. Those three stay how they are while others in the list has the code run on them.

    Which sheets the code runs on should not be hard coded in the code itself. I have seen things like Dim as selected for a code using a selection of cells. Is there a way for the code to have some sort of Dim as selected run on sheetnames that are selected?

    Thanks, appreciate your help!