Dean
The worksheets are known within Excel as a collection (A collection of
worksheet objects). A very good way or iterating through each element in a
collection is a for each...next loop. All my code does is declares a
variable (wks, but could be called anything valid), which holds a worksheet
object each time it loops through the collection, so no matter how many you
add or take away, each one gets looked at. This then means that wks is
actually the 'current' worksheet object you are looking at, so to use your
protect code you would just use...
wks.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
This saves all the selecting, activating, etc which slows code down. My
point about defaults still stands. The above is actually setting everything
to True which is a default so the cod above is equivalent to
wks.Protect
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
www.nickhodge.co.uk