My challenge is to export multiple excel sheets by using checkbos. I have done the script as below, but it only works if one check box is selected. The row "Sheets(Array(tuloste)).Select" is giving error when both or none checkboxes are selected.
Private Sub CommandButton1_Click()
Dim nimi
Dim tarjousnumero
Dim polku
Dim sivut As String
Dim Liite1
Dim Liite2
If CheckBox1.Value = True Then
Liite1 = "Palvelukuvaus"
Else
Liite1 = ""
End If
If CheckBox2.Value = True Then
Liite2 = "Etävalvonta"
Else
Liite2 = ""
End If
tuloste = Liite1 & Liite2
ActiveWorkbook.Save
Range("I2").Activate
tarjousnumero = ActiveCell
nimi = InputBox("Anna tiedoston nimi", "Tallenna pdf muodossa", "Tarjous " & tarjousnumero)
polku = ActiveWorkbook.Path
Sheets("Kaupallinen tarjous").Select
Sheets(Array(tuloste)).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=polku & "\" & nimi & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _OpenAfterPublish:=False
Sheets("Kaupallinen tarjous").Select
UserForm2.Hide
End Sub