title: Print range in excel vba
body: <p>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?</p>
  
  <p>Thanks </p>
  
  <pre><code>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
  </code></pre>