Select All Worksheets in Excel VBA

  Desert Andy 18:21 21 Mar 07

If I want to select all the worksheets in a workbook to print preview, what code should I use.


  VoG II 18:33 21 Mar 07

Something like

Sheets(Array("Sheet17", "Sheet16", "Sheet15", "Sheet14", "Sheet13", "Sheet12", "Sheet11", "Sheet10")).Select

  VoG II 18:38 21 Mar 07

Or even


  Desert Andy 18:39 21 Mar 07

The trouble is I don't know how many sheets there are in the workbook, since it is a database, so I wanted to try and select all without naming all the sheets in an array. Any code like select all sheets?

  VoG II 18:40 21 Mar 07

Yep - just thought of it :o)

  VoG II 18:58 21 Mar 07

This even better as it avoids Selecting altogether and is one less line of code:


This thread is now locked and can not be replied to.

Sony Xperia XZ Premium review: Hands-on with the new 4K HDR phone with Motion Eye camera and Snapdr5…

1995-2015: How technology has changed the world in 20 years

Best laptop for design and art 2017: we test Apple, Dell, HP, Lenovo and Microsoft's best models…

CarPlay tips & troubleshooting guide: CarPlay tips & troubleshooting guide: Get the most from…