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

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Sheetname1[/TD]
[TD]1[/TD]
[TD]Sheetname1[/TD]
[/TR]
[TR]
[TD]Sheetname2[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sheetname3[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sheetname4[/TD]
[TD]1[/TD]
[TD]Sheetname4[/TD]
[/TR]
[TR]
[TD]String Name[/TD]
[TD]
[/TD]
[TD]"Sheetname1", "Sheetname4"[/TD]
[/TR]
</tbody>[/TABLE]









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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,223,920
Messages
6,175,377
Members
452,638
Latest member
Oluwabukunmi

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