title: Dynamic Sheets(Array())
body: <p>I want to select a array of sheets using the Sheets(Array()) method.
  The sheets I want to select are named in the cells of my workheet Printlist.
  The sheetnames are listed form column D to K. </p>
  
  <p>Not all cells are filled so if I use the folowing function it errors on the rows with blank cells. How can I avoid this error:</p>
  
  <p>This is what the sheet looks like: 
  <a href="https://i.stack.imgur.com/uJqZc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uJqZc.jpg" alt="enter image description here"></a></p>
  
  <p>And this is the code</p>
  
  <pre><code>Sub PDF_maken()
  
      Dim ws As Worksheet
      Dim LR As Long
      Dim r As Range
      Dim Mypath As String
      Dim strarray As String
  
      Set ws = ActiveWorkbook.Worksheets("Printlijst")
      LR = ws.Cells(Rows.Count, 1).End(xlUp).Row
  
      For Each r In ws.Range("B20:B20").Cells
  
          If Not IsEmpty("B" &amp; r.Row) Then
  
              Mypath = ws.Range("B" &amp; r.Row).Text
              colCheck = 4
  
              Do Until Cells(r.Row, colCheck) = ""
                 strarray = strarray &amp; IIf(colCheck &gt; 4, ",") &amp; """" &amp; Cells(r.Row, colCheck).Value &amp; """"
                  colCheck = colCheck + 1
              Loop
  
              ActiveWorkbook.Sheets(strarray).Select
              ActiveWorkbook.SelectedSheets.ExportAsFixedFormat _
                                  Type:=xlTypePDF, _
                                  Filename:=Mypath &amp; ws.Range("C" &amp; r.Row).Text &amp; ".pdf", _
                                  Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                                  IgnorePrintAreas:=False, OpenAfterPublish:=False
          End If
      Next r
  
  End Sub
  </code></pre>