• Good afternoon to all:

    I was given the following VBA to make changes to a specific cell range. The VBA works great, but it does the change to all of my worksheet. I was ten given information on how to make the VBA good for only a group of Worksheets, But I do not know how to put it together. I do not know VBA. Some one please help...

    1) Below is VBA that makes changes to all worksheets:

    2) AND this is the suggestion I got to make changes only in a group of worksheet:

    Dim WorksheetName As Variant
    For Each WorksheetName In Array("Sheet4", "Sheet6", "Sheet8")
    If WorksheetName <> cws.Name Then
    ThisWorkbook.Worksheets(WorksheetName).Range(addr) = chg
    End If
    Next WorksheetName

    3) Can Someone please help me put it together?

    Thank you so much

  • Thank you for your quick response.

    This is what I did and I get an error in the highlighted and underlined in red spot below

  • Yes, you missed one of the five lines, the first, this one:

    For Each ws In Worksheets

    was to substituted with:

    For Each WorksheetName In Array("BATHROOM", " BATHROOM2", " BATHROOM3")

    you just added it.

    As you can see in the section "' Loop through other sheets and make the same changes" at the moment you have two 'For' and only one 'Next'. Doing so VBE will non compile the code.

  • Vnaza112

    Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post

    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.

    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.


    your code goes between these tags


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


  • Try this

  • royUK, Thank you so much for taking the time to help me. I just do not get it. I tried it, but it is not working.

    I will not take up any more of your time, but I really want thank you for what you have given me to this point. It means a lot.

    Happy Holidays and I wish you a Safe and Healthy New Years!


Participate now!

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