I am putting together a template file that users will copy sheets into, and run macros to create reports. I'm trying to use VBA to set the print range for a pivot table, when the number of rows and columns can be different for each report created (i.e., each time the template is used).
I'm getting a Run-time error '1004' The formula you typed contains an error on this line:
ActiveSheet.PageSetup.PrintArea = "BHPivot!R1C1:R" & lrow& "C" & lcol
The code is as follows:
I adapted this from code I used to set a dynamic pivot table range, and it works perfectly for that use. Just can't figure out why it's giving an error here.
Thanks so much!
<strike></strike>
I'm getting a Run-time error '1004' The formula you typed contains an error on this line:
ActiveSheet.PageSetup.PrintArea = "BHPivot!R1C1:R" & lrow& "C" & lcol
The code is as follows:
Rich (BB code):
Dim lcol As Long
Dim lrow As Long
lrow =Sheets("BHPivot").Range("a" & Rows.Count).End(xlUp).Row
lcol =Sheets("BHPivot").Cells(lastrow, Columns.Count).End(xlToLeft).Column
ActiveSheet.PageSetup.PrintArea ="BHPivot!R1C1:R" & lrow & "C" & lcol
I adapted this from code I used to set a dynamic pivot table range, and it works perfectly for that use. Just can't figure out why it's giving an error here.
Thanks so much!
<strike></strike>