I'm very new to <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: dotted; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(0, 0, 0); border-left-color: initial; border-image: initial; cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym> and am having issues with a project I am working on. I have a workbook that contains 15 sheets with different data types in each. There is a home page with hyperlinks to each sheet. All sheets have a title and link to the home page on the top of the sheet. The goal is to have this workbook converted to PDF. However I do not want the Home page ever included or the title and link on the separate sheets. And not all sheets will always be converted. The idea I was going with was: the user will place and x in the cell next to the pages (on the home page list) they want to include and a for loop will find the sheets without and hide them before hiding the home page and finally converting to pdf. How would this be done? The sheets vary quite a bit and I have been having issues fitting them on PDF pages correctly. Is there an easy way to resolve this?
Here is what is have so far and like I said no experience with <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: dotted; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(0, 0, 0); border-left-color: initial; border-image: initial; cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym>: the bold is what is currently failing, its an attempt to take the text in a cell that corresponds to a sheet and then activate that sheet. It does not work.
Private Sub CommandButton1_Click()
Dim i As Integer
Dim page As String
Dim tabs As Integer
Dim WB As Workbook
Dim sheet As Worksheet
Set WB = ActiveWorkbook
tabs = WB.Sheets.Count
For i = 1 To tabs
page = Sheets("HOME").Range("C" & (i + 12)).Text
If Len(Trim(Range("C" & (i + 12))) = 0) Then
Sheets(" 'page' ").Activate
sheet.Visible = xlSheetHidden
End If
Next
Worksheets("HOME").Activate
ActiveSheet.Visible = xlSheetHidden
End Sub
Here is what is have so far and like I said no experience with <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: dotted; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(0, 0, 0); border-left-color: initial; border-image: initial; cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym>: the bold is what is currently failing, its an attempt to take the text in a cell that corresponds to a sheet and then activate that sheet. It does not work.
Private Sub CommandButton1_Click()
Dim i As Integer
Dim page As String
Dim tabs As Integer
Dim WB As Workbook
Dim sheet As Worksheet
Set WB = ActiveWorkbook
tabs = WB.Sheets.Count
For i = 1 To tabs
page = Sheets("HOME").Range("C" & (i + 12)).Text
If Len(Trim(Range("C" & (i + 12))) = 0) Then
Sheets(" 'page' ").Activate
sheet.Visible = xlSheetHidden
End If
Next
Worksheets("HOME").Activate
ActiveSheet.Visible = xlSheetHidden
End Sub