Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Leo
one way: Sub test() For Each ws In Worksheets Debug.Print ws.Name Next 'ws End Sub Regards Trevor "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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Leo
Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Name = "ddd" Then '.................. End If Next sh -- Regards Ron de Bruin http://www.rondebruin.nl "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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop or Find code ?? need help !! | Excel Worksheet Functions | |||
Loop for VBA code? | Excel Worksheet Functions | |||
How to Loop some code | Excel Discussion (Misc queries) | |||
VBE code in a loop | Excel Programming | |||
Creating a loop from my code | Excel Programming |