title: Excel vba code to print
body: <p>So with your guys help I made a macro that would read down a singular column and find the last cell that has data entered into it. I then wanted to add nested if then elseif statements that would tell it to print x number of pages based on when the last cell is listed. This is the code im using. What am I doing wrong?</p>
  
  <pre><code>    Sub LastRowInOneColumn()
      'Updateby20150305
      Dim xLastRow As Long
      With Application.ActiveSheet
          xLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
      End With
      MsgBox xLastRow
  
      If xLastRow = "22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,30,40,41,42,43,44,45" Then
  
      Application.Dialogs(xlDialogPrinterSetup).Show
      'Worksheets("Sheet1").PrintOut From:=1, To:=1, Preview:=True
  
      End If
  
  End Sub
  </code></pre>