This,
Range("B" & StartRow & ":J" & EndRow).Interior.ColorIndex = xlNone
will refer to the active sheet, as will Rows here.
If Not Rows(i).Hidden Then
Try passing the worksheet ws as well as StartRow and EndRow.
Public Sub Band()
Dim wb As Workbook
Dim ws As Worksheet
Dim eRow As Integer
Set wb = ThisWorkbook
Set ws = wb.Sheets(1)
With ws
fRow = .Cells(Rows.Count, 1).End(xlUp).Row
eRow = fRow
BandRows ws, 54, eRow
End With
End Sub
Private Sub BandRows(ws As Worksheet, StartRow As Integer, EndRow As Integer)
With ws
.Range("B" & StartRow & ":J" & EndRow).Interior.ColorIndex = xlNone
For i = StartRow To EndRow
If Not .Rows(i).Hidden Then
nohide = nohide + 1
If Not nohide Then
.Range("B" & i & ":J" & i).Interior.Color = RGB(225, 225, 225)
End If
End If
Next i
End With
End Sub
Bookmarks