bobkap
Active Member
- Joined
- Nov 22, 2009
- Messages
- 323
- Office Version
- 365
- Platform
- Windows
- Mobile
- Web
I cannot get this code to run except for my active sheet. I will not sequence to the next sheets in the workbook. Any help would be greatly appreciated.
finalcol = Cells(1, Columns.Count).End(xlToLeft).Column
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Instpay" Or ws.Name <> "Payroll Data" Then
grosscol = Application.Match("Gross", Range("1:1"), 0)
grosstot = WorksheetFunction.Sum(Range(Cells(2, grosscol), Cells(finalrow, grosscol)))
Cells(finalrow + 1, grosscol).Value = grosstot
Cells(finalrow + 1, grosscol).Select
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End If
Next ws
finalcol = Cells(1, Columns.Count).End(xlToLeft).Column
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Instpay" Or ws.Name <> "Payroll Data" Then
grosscol = Application.Match("Gross", Range("1:1"), 0)
grosstot = WorksheetFunction.Sum(Range(Cells(2, grosscol), Cells(finalrow, grosscol)))
Cells(finalrow + 1, grosscol).Value = grosstot
Cells(finalrow + 1, grosscol).Select
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End If
Next ws