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: http://icons.iconarchive.com/icons/double-j-design/ravenna-3d/24/File-Copy-icon.png]

    Code
    Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
    Range("D4").GoalSeek Goal:=0, ChangingCell:=Range("C13")
    Application.EnableEvents = True
    End

    Is this possible?


    All help is appreciated. Thanks!


    -Sky

  • 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 "Smiley" icon, below, in 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!


    -Sky

  • Glad you could fix your problem


    Thanks for your Thanks ... AND for the Like :)

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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!