Q:

Save new workbook from selected sheets

So my main goal is to save sheets (depending on if they are selected by a checkbox on the front page) to a new workbook.
I have 6 sheets, so I have 6 different checkboxes on my front page/sheet.
Here is my example code I've tried (Note: this only shows a check for 1 checkbox, however I require this for 6 checkboxes):
Sub saveSheetWorkbook()

Dim exampleName As Variant
Dim exampleSavePath As String
Dim exampleSheet As Variant

exampleName = InputBox("Who will this be sent to?")

exampleSavePath = ActiveWorkbook.Path & "\" & exampleName

If Worksheets("Example Worksheet 1").Range("E29") = True Then
exampleSheet = "Example Worksheet 2"
End If

Sheets(Array("Example Worksheet 1"), exampleSheet).Copy
ActiveWorkbook.SaveAs Filename:=exampleSavePath, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

End Sub

For example, I want to always save Example Worksheet 1, but only save Example Worksheet 2 (and 3,4,5,6) if the checkbox is ticked. The cell E29 in Example Worksheet 1 is the linked cell for the checkbox.
So this macro works when the checkbox is ticked, but when the checkbox is unticked, I get an error.
I have set it up so that the sheet array either contains the name or nothing. but when containing nothing, that gives me the error.
Any help would be great.

A:

you may want to act like follows (see comments):
Option Explicit

Sub saveSheetWorkbook()
    Dim exampleSavePath As String
    Dim sheetsArr As Variant, linkedCellsArr As Variant
    Dim toBeCopiedSheetsNames As String
    Dim iElem As Long

    linkedCellsArr = Array("E29", "E30", "E31") '<--| list your linked cells addresses
    sheetsArr = Array("Example Worksheet 2", "Example Worksheet 3", "Example Worksheet 4") '<--| list your worksheets in corresponding order to linkedcells

    toBeCopiedSheetsNames = "Example Worksheet 1" '<--| put "Example Worksheet 1" worksheet in the worksheets to be copied list for sure
    For iElem = LBound(linkedCellsArr) To UBound(linkedCellsArr) '<--| loop through linked cells (addresses array)
        If Range(linkedCellsArr(iElem)) Then toBeCopiedSheetsNames = toBeCopiedSheetsNames & "|" & sheetsArr(iElem) '<-- if TRUE then add corresponding worksheet name to the worksheet to be copied list
    Next iElem

    exampleSavePath = ActiveWorkbook.Path & "\" & Application.InputBox("Who will this be sent to?", Type:=2) '<--| retrieve the file name and build its "full" name

    Sheets(Split(toBeCopiedSheetsNames, "|")).Copy '<--| copy worksheets whose name is listed in 'toBeCopiedSheetsNames'
    ActiveWorkbook.SaveAs Filename:=exampleSavePath, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub

