title: Select a specific area of selected cells to PDF then print using VBA in a worksheet
body: <p>i have this worksheet called Test. In that worksheet i want to export to pdf then print cells G1 to cells H17. Next i want to print G1 to cells I17 skipping column H meaning without column H. In another word column G is kind of like the header and the columns that follow the result. So print Header column+ results column and so on until column CM. Below each printing page i want to also export to pdf column C18, column D18 and Column H18 if cells I18 to cells I27=500. I started the code but couldn't go on to finish it since i am not really versed in vba</p>
  <pre class="lang-vb prettyprint-override"><code>Sub SetPrintArea()
     Dim ws As Worksheet
     Dim x As Long, result As Boolean
     result = True
  For x = 18 To 128
     If Worksheets(&quot;AR-MD&quot;).Range(&quot;H&quot; &amp; x).Value &lt;&gt; ActiveSheet.Cells(8, 19).Value Then
         result = False
     End If
     If Not result Then Exit For
  Next x
      
  Set ws = ThisWorkbook.Sheets(&quot;AR-MD&quot;)
  
  
  ws.PageSetup.PrintArea = Union(ws.Range(&quot;g1:g17&quot;), ws.Range(&quot;i1:i17&quot;),ws.Range(&quot;Result&quot;).Address
  
  End Sub
  
  
  I want to be able to print the result condition but i dont know how to include it in the statement
  </code></pre>