Using a text string in a cell as an Printout Array

Joined
Apr 2, 2018
Messages
1
Hi - I am very new to the world of VBA and am hoping to get help with the scenario below. I have a workbook with over 6 sheets, 4 of which can be printed by the user. One of sheets is a "form" sheet, one is a "controls" sheet. I want to make it so the user can select which of the pages to print by clicking on a picture on the "form" sheet (similar to a checkbox). Each picture has a macro that updates a table on the "controls" sheet with a 1 or 0. The table on the "controls" page is 3 columns by 5 rows:
  • The first column is the titles of the 4 sheet names that can be printed; each on their own row
  • The second column is updated by a macro on the form sheet. Each cell is updated with a 1 to inlcude the page in print job and 0 to leave it out of print job
  • The third column is a formula the builds a text string with if then statements. (If column (2) is 1 then "text in column 1", if not "")
  • The 5th row concatenates the text in column 3 in this format -- "Sheetname1", "Sheetname2", "Sheetname3", "Sheetname4"

I illustrated the table below. In this illustration let’s assume that this table starts on "controls" A1 and the red text is in C5

Sheetname11Sheetname1
Sheetname20
Sheetname30
Sheetname41Sheetname4
String Name
"Sheetname1", "Sheetname4"

<tbody>
</tbody>









I want to use the red text in this example in the VBA Macro below to printout. I have tested the VBA below and it works if the text in blue text is typed in. I want to replace the blue text below with the dynamic string in red text above. This is where I am stumped.

ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\tempo.pdf", Quality:= xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True

Thanks for reading!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top