ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Problem (https://www.excelbanter.com/excel-programming/380331-macro-problem.html)

hazel

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

JE McGimpsey

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


hazel

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




All times are GMT +1. The time now is 04:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com