Forum Discussion

JoeCavasin's avatar
JoeCavasin
Brass Contributor
Sep 23, 2023
Solved

Excel VBA - Loop through sheets testing same cell for input box string/value

HansVogelaar  - guessing you're the guy to ask this VBA question.   The attached sheet functions great, except one time - when a user opts to run the "Create New User Tab" prior to the new month.  ...
  • HansVogelaar's avatar
    Sep 23, 2023

    JoeCavasin 

    NewMonth is a string variable, so you refer to its value by using its name: NewMonth.

    A string is not an object, so you should not use NewMonth.Value.

     

    As far as I can tell (I have not tested the code, for I don't want to close all other workbooks), the first loop in TESTUpdateCalcsV2 should be

        For Each Ws In ThisWorkbook.Worksheets
            If Ws.Name <> "Template" And Ws.Name <> "User List" Then
                With Ws
                    If Ws.Range("A11").Value <> NewMonth Then
                        .Rows(iRow).EntireRow.Insert
                        .Rows(iRow).EntireRow.Insert
                    End If
                End With
            End If
        Next Ws

Resources