Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Macro Problem

Hi All
I have a problem with the following macro -- I do not want it to run after
it gets to sheet 25 - Sheet 26 ad infinitum may have different names in the
workbook -- is it possible for this to be done?? If so can anyone guide me in
the right direction.


Sub Macro6()

For Each ws In Worksheets
If ws.Name < "Club Account" And ws.Name < "Result" And ws.Name <
"LONGDENDALE" And ws.Name < "Account" And ws.Name < "Sheet1" And ws.Name <
"Expenses" Then


With ws



..Range("F3:F52").Copy .Range("H3")
..Columns("H:H").Insert Shift:=xlToRight
..Range("F3:F52").ClearContents
..Columns("H:IV").Columns.ColumnWidth = 15

'Sheets("Account").Range("A2:C26").ClearContents
'Application.Goto Sheets("M.Hall").Range("F3")

Dim cell As Range


..Range("I3:I53").Interior.ColorIndex = xlNone
For Each c In .Range("I3:I53")
If IsNumeric(c) And c.Value 5 Then c.Interior.Color = RGB(0, 255, 0)
Next c

End With
End If
Next ws

End Sub

--
Many thanks

hazel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro Problem

One way:

For Each ws In Worksheets
If ws.Index 25 Then Exit For
'Rest of your code


In article ,
Hazel wrote:

Hi All
I have a problem with the following macro -- I do not want it to run after
it gets to sheet 25 - Sheet 26 ad infinitum may have different names in the
workbook -- is it possible for this to be done?? If so can anyone guide me in
the right direction.


Sub Macro6()

For Each ws In Worksheets
If ws.Name < "Club Account" And ws.Name < "Result" And ws.Name <
"LONGDENDALE" And ws.Name < "Account" And ws.Name < "Sheet1" And ws.Name <
"Expenses" Then


With ws



.Range("F3:F52").Copy .Range("H3")
.Columns("H:H").Insert Shift:=xlToRight
.Range("F3:F52").ClearContents
.Columns("H:IV").Columns.ColumnWidth = 15

'Sheets("Account").Range("A2:C26").ClearContents
'Application.Goto Sheets("M.Hall").Range("F3")

Dim cell As Range


.Range("I3:I53").Interior.ColorIndex = xlNone
For Each c In .Range("I3:I53")
If IsNumeric(c) And c.Value 5 Then c.Interior.Color = RGB(0, 255, 0)
Next c

End With
End If
Next ws

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Macro Problem

Thank you very much -- problem solved -- what would we do without your
expertise
--
Many thanks

hazel


"JE McGimpsey" wrote:

One way:

For Each ws In Worksheets
If ws.Index 25 Then Exit For
'Rest of your code


In article ,
Hazel wrote:

Hi All
I have a problem with the following macro -- I do not want it to run after
it gets to sheet 25 - Sheet 26 ad infinitum may have different names in the
workbook -- is it possible for this to be done?? If so can anyone guide me in
the right direction.


Sub Macro6()

For Each ws In Worksheets
If ws.Name < "Club Account" And ws.Name < "Result" And ws.Name <
"LONGDENDALE" And ws.Name < "Account" And ws.Name < "Sheet1" And ws.Name <
"Expenses" Then


With ws



.Range("F3:F52").Copy .Range("H3")
.Columns("H:H").Insert Shift:=xlToRight
.Range("F3:F52").ClearContents
.Columns("H:IV").Columns.ColumnWidth = 15

'Sheets("Account").Range("A2:C26").ClearContents
'Application.Goto Sheets("M.Hall").Range("F3")

Dim cell As Range


.Range("I3:I53").Interior.ColorIndex = xlNone
For Each c In .Range("I3:I53")
If IsNumeric(c) And c.Value 5 Then c.Interior.Color = RGB(0, 255, 0)
Next c

End With
End If
Next ws

End Sub


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"