Forum Discussion

mdevola89's avatar
mdevola89
Copper Contributor
Dec 13, 2022
Solved

Macro to print pages

I have numerous sheets in a workbook and I'm trying to print a number of pages for each based on a value in a cell. I am not sure what I am missing to make this work. Any ideas will be greatly apprci...
  • HansVogelaar's avatar
    HansVogelaar
    Dec 14, 2022

    mdevola89 

    The part

     

    If Worksheets("CMM Report (" & i & ")").Visible = True Then Worksheets("CMM Report (" & i & ")").Activate

    Else

    Exit For ' stop the loop if a sheet is missing

    End If

     

    should be

            If Worksheets("CMM Report (" & i & ")").Visible = True Then
                Worksheets("CMM Report (" & i & ")").Activate
            Else
                Exit For ' stop the loop if a sheet is missing
            End If

     

Resources