title: Select and print multiple sheets in one print job Excel VBA
body: <p>I have inherited this awfulness, and been asked to make updates. </p>
  
  <p>Currently this workbook is built with one sheet that has a bunch of checkboxes, all associated with other sheets in the workbook. The user selects checkboxes, and then hits a button to print the sheets associated with each checkbox that is checked. </p>
  
  <p><strong>The way it's built now, it runs a print job for each sheet selected. I have been asked to run one print job for all sheets selected (to avoid having a hundred cover sheets).</strong></p>
  
  <p>I have written a little VBA function that produces a string containing the name of every sheet for which the checkbox is checked, in quotes, comma separated.</p>
  
  <p>I need to figure out a way to use this information to select all the sheets and then print once each sheet I need is selected.</p>
  
  <p>Or even hell, I'd take being able to spit this string back into the macro that was originally written for the print ability. Right now the macro is another sheet in the workbook, and has 102 different print commands, controlled by a bunch of if statements. So I'd take being about to spit the string into that sheet so I could run one print command.</p>
  
  <p>Either way, someone please help.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Public Function sheetString()
      Dim c As Integer
      Dim r As Integer
      Dim sConcat As String
  
      Dim ws As Worksheet
  
      For c = 2 To 6 Step 2
          For r = 1 To 46
              If Sheet94.Cells(r, c) = True Then
                 sConcat = sConcat &amp; Sheet94.Cells(r, c - 1) &amp; ", "
              End If
          Next r
      Next c
  
      sConcat = Left(sConcat, Len(sConcat) - 2)
  
      Debug.Print sConcat
  End Function
  </code></pre>
  
  <p>The output of the code is like this (with varying names depending on which boxes are checked):</p>
  
  <blockquote>
    <p>"PR015", "PR018", "PR019", "PR026", "PR029A"</p>
  </blockquote>
  
  <p>EDIT: Thanks to simoco, I'm closer than I've been so far. Here is the code as it stands now.</p>
  
  <pre><code>Public Function sheetString()
      Dim c As Integer
      Dim r As Integer
      Dim sConcat As String
      Dim ws As Worksheet
  
      Set ws = Sheet94
  
      For c = 2 To 6 Step 2
          For r = 1 To 46
              If ws.Cells(r, c) = True Then
                 sConcat = sConcat &amp; ws.Cells(r, c - 1) &amp; ","
              End If
          Next r
      Next c
      sConcat = Left(sConcat, Len(sConcat) - 1)
      Debug.Print sConcat
      sheetString = sConcat
  End Function
  
  Sub test()
      'if cells with sheet names contains quotes
      'Sheets(Split(Replace(sheetString, """", ""), ",")).Select
      'if cells with sheet names doesn't contain quotes
      Sheets(Split(sheetString, ",")).Select
      ActiveSheet.PrintOut Copies:=1
  End Sub
  </code></pre>
  
  <p>It's running without bombing out, but now it's only selecting the first sheet that has it's box checked.</p>