I'm trying to select a range of worksheets in an Excel macro, so that they can then be printed.
I want to print a range, i.e. Sheet2-Sheetx, where x is a variable.
I have tried recording a macro to do what I want, but it uses sheet names rather than sheet references, and of course doesn't support variables.
In this example, I selected three sheets, so x=3:
Sheets(Array("Data", "Data (2)", "Data (3)")).Select
ActiveWindow.SelectedSheets.PrintOut preview:=True
I would have thought this would be simple, but can't seem to figure it out.
Thanks in advance.