There are two problems with the code.
First, you are setting ClrArray to a collection of sheets. Then, you
are trying to use this collection of *objects* as indices to the
Worksheets collection. That cannot work because the Worksheets
collection can be indexed only by integers or strings (and not
objects).
You should use
'Set ClrArray = ActiveWorkbook.Sheets(Array("Forecast", _
"LMU", "Kit", "SMLC", "WLG", _
"SMLC Cab", "Serv Cab", "Ntwk Kit", _
"TDAX", "EMS", "SCOUT", "Dir Coup"))
ClrArray = Array("Sheet1", "Sheet2", "Sheet3")
ActiveWorkbook.Sheets(ClrArray).Select
In the above example, your statment has been commented out. My test
used just three worksheets. Note that in my case, clrarray contains
*string* values not worksheet objects.
However, that still leaves the 2nd problem. XL's handling of 3D ranges
is something I would describe as a layer slapped on over the existing
object model. Since it doesn't quite fit in with the OM, you have to
rely on the 'selection' to make things happen. The code below works.
Note that, once again, the correct clrarray statement for you exists
only as a comment.
Option Explicit
Option Explicit
Sub testIt()
Dim ClrArray
'ClrArray = Array("Forecast", _
"LMU", "Kit", "SMLC", "WLG", _
"SMLC Cab", "Serv Cab", "Ntwk Kit", _
"TDAX", "EMS", "SCOUT", "Dir Coup")
ClrArray = Array("Sheet1", "Sheet2", "Sheet3")
ActiveWorkbook.Sheets(ClrArray).Select
Sheets(ClrArray(LBound(ClrArray))).Activate
Range("A5:EC500").Select
Selection.ClearContents
End Sub
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions