I am trying to automate the number of pages to print, where a user inputs a set of data and it populates a sheet. Depending on how many items of data they add, the sheet I want to print could be 1 page, up to 3 pages.
So the sheet that presents this data has 3 copies of the same template.
I have a formula in a cell which works out how many pages to print.
Dim ToPrint As Integer
ToPrint = Sheets("Sheet7").Range("Too")
Application.ScreenUpdating = False
Sheets("CI").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\PDF Files\Export.pdf", _
OpenAfterPublish:=True, _
From:=1, _
To:=ToPrint
Sheets("Sheet7").Select
Application.ScreenUpdating = True
The bit with ToPrint doesn't seem to be working as expected.
Range("Too") is reference to a single cell, which holds the formula, which is an if statement which can be 1, 2 or 3.
When I run it, I get an error. run time error -2147018887 (80071779).
Please can someone help me?