Hi there - reacquainting myself with VBA and I seem to be a bit rusty.
To this point I have been able to successfully write code that will save a constant set of worksheets as a pdf. However, I would now like to alter it to be able to dynamically select the desired worksheets from a list box (I have been able to populate my list box) and then save as a pdf. The last step is where I am have issues. This is what I have thus far..
Dim relativePath As String
Dim Selected As Long
For Selected = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(Selected) = True Then
Sheets("Summary").Range("Q65536").End(xlUp)(2, 1) = ListBox1.List(Selected)
ListBox1.Selected(Selected) = False
End If
Next
relativePath = ThisWorkbook.Path & "\" & Sheets("Title").Range("B28").Value
Sheets (Array(ListBox1.Selected(Selected)))
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=relativePath
End With
Any insight is appreciated!
Thanks,
Thomas
To this point I have been able to successfully write code that will save a constant set of worksheets as a pdf. However, I would now like to alter it to be able to dynamically select the desired worksheets from a list box (I have been able to populate my list box) and then save as a pdf. The last step is where I am have issues. This is what I have thus far..
Dim relativePath As String
Dim Selected As Long
For Selected = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(Selected) = True Then
Sheets("Summary").Range("Q65536").End(xlUp)(2, 1) = ListBox1.List(Selected)
ListBox1.Selected(Selected) = False
End If
Next
relativePath = ThisWorkbook.Path & "\" & Sheets("Title").Range("B28").Value
Sheets (Array(ListBox1.Selected(Selected)))
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=relativePath
End With
Any insight is appreciated!
Thanks,
Thomas