0

I have a pivot that returns data to letting me know what pages in a sheet in need to print. I am looking at using VBA to output based on the pivot. I can't get the range to work. I am I missing something?

Thanks

Sub RectangleRoundedCorners1_Click()

    If Range("M4").Value = 1 Then
        Worksheets("Pivot").PageSetup.PrintArea = "A1:H35"
        ActiveSheet.PrintOut

        If Range("M5").Value = 2 Then Worksheets("Pivot").PageSetup.PrintArea = "A36:H71"
            ActiveSheet.PrintOut

            If Range("M6").Value = 3 Then
                Range("A72:H107").PrintOut

                If Range("M7").Value = 4 Then
                    Worksheets("Pivot").PageSetup.PrintArea = "A108:H143"
                    ActiveSheet.PrintOut

                    If Range("M8").Value = 5 Then
                        Range("A144:H179").PrintOut

                        If Range("M9").Value = 6 Then
                            Range("A180:H215").PrintOut

                            If Range("M10").Value = 7 Then
                                Range("A216:H251").PrintOut

                                If Range("M11").Value = 8 Then
                                    Range("A252:H287").PrintOut

                                    If Range("M12").Value = 9 Then
                                        Range("A288:H323").PrintOut

                                        If Range("M13").Value = 10 Then
                                            Range("A324:H359").PrintOut

                                            If Range("M14").Value = 11 Then

                                                Range("A360:H395").PrintOut
                                                If Range("M15").Value = 12 Then

                                                    Range("A396:H431").PrintOut
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If
End Sub
0

1 Answer 1

1

Here's a snippet of the code. You'll have to change the rest of them.

If Range("M6").Value = 3 Then
   Range("A72:H107").Select
   ActiveSheet.PageSetup.PrintArea = "A72:H107"
   ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.