View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Code to Loop thru a Workbook

WsCount = Worksheets.Count

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Leo" wrote in message
...
We have a macro in which we want to loop through the
worksheets but don't know the number of worksheets. We
want to loop through and activate a worksheet if it meets
certain criteria, but don't know the code to do this. Are
we on the right track below? Can someone fill in the two
missing pieces of code in the parens below?


Sub WorksheetLoop ()

Dim WsCount as Double

WsCount = (How do we get this?)

For I = 1 to WsCount
If (How do we identify the worksheet name here in
VB?) = "AA" then
VB lines of code here
End If
Next I

End Sub