D
Dave Birley
I have a WB with 19 WS in it. I have a set of Macros (3 so far) which are
intended to work on each WS individually. They starts off similarly to this:
myCount = 0 'Counts the Rows in the inner loops
NewStartRow = 2 'Start Row of each set
myRowCount = 0 'Counts the Rows in the outer loop
With ActiveSheet
Set rngLastRow = .Cells(.UsedRange.Rows.Count,
..UsedRange.Columns.Count).EntireRow
End With
Do While NewStartRow <= rngLastRow.Row 'Check every row
If myRowCount > rngLastRow.Row Then
Exit Do
End If
Set myCell = Cells(NewStartRow + myRowCount, 3) 'First time starts
in Row 2
When I run them I discover that they are each running on all 19 pages at the
same time. I just thought, there is some other code in the Macro that might
be the guilty party. It is this:
If mySubTotal <> CurVal Then 'Highlight set where there is a
mis-match
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & NewStartRow - varOffset), ("S" &
NewStartRow - 1)).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
End If
Is the problem in that "Range(Selection...)" stuff?
intended to work on each WS individually. They starts off similarly to this:
myCount = 0 'Counts the Rows in the inner loops
NewStartRow = 2 'Start Row of each set
myRowCount = 0 'Counts the Rows in the outer loop
With ActiveSheet
Set rngLastRow = .Cells(.UsedRange.Rows.Count,
..UsedRange.Columns.Count).EntireRow
End With
Do While NewStartRow <= rngLastRow.Row 'Check every row
If myRowCount > rngLastRow.Row Then
Exit Do
End If
Set myCell = Cells(NewStartRow + myRowCount, 3) 'First time starts
in Row 2
When I run them I discover that they are each running on all 19 pages at the
same time. I just thought, there is some other code in the Macro that might
be the guilty party. It is this:
If mySubTotal <> CurVal Then 'Highlight set where there is a
mis-match
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & NewStartRow - varOffset), ("S" &
NewStartRow - 1)).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
End If
Is the problem in that "Range(Selection...)" stuff?