For/Next Loop through worksheets
Set wb = ActiveWorkbook
Set sh = ActiveSheet
For Each ws In wb
If ws.Name < "SUMMARY" and _
ws.Name < "Parameters" and _
ws.Name < "PIVOTDATA" and _
ws.Name < "PIV_Deliverables" and
ws.Name < "PIV_RC" Then
ws.Activate
Call Formatting
Next ws
Application.Goto "Summary_Home"
--
Regards,
Tom Ogilvy
"klysell" wrote:
Hi,
I am trying to call up formatting procedures to format sheets, but I don't
want to apply the formatting procedures to any sheet with one of the five
names as indicated in the sample code below. Why am I getting an error
message telling me "Next without For"? Is there a more efficient way to
execute this code?
Here is the sample code:
Set wb = ActiveWorkbook
Set sh = ActiveSheet
For Each ws In wb
If ws.Name = "SUMMARY" Then
If ws.Name = "Parameters" Then
If ws.Name = "PIVOTDATA" Then
If ws.Name = "PIV_Deliverables" Then
If ws.Name = "PIV_RC" Then
GoTo He
Call Formatting
Next ws
He
Application.Goto "Summary_Home"
Thanks in advance!
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557
|