I want to repeat this code on all the worksheets in a workbook.
There may sometimes be 1-2 worksheets sometimes 50+.
Sub HoursTotal()
\'
\' HoursTota
Simple modification of your current code should do it:
Sub HoursTotal()
'
' HoursTotal Macro
'
Dim ws as Worksheet
For Each ws in Worksheets
ws.Range("F2").Select
ActiveCell.FormulaR1C1 = "=SUM(C[-1])"
ws.Range("F1").Select
ActiveCell.FormulaR1C1 = "Total Hours"
ws.Range("G1").Select
Next ws
End Sub
But here's what it looks like without the Select's
Sub HoursTotal()
'
' HoursTotal Macro
'
Dim ws as Worksheet
For Each ws in Worksheets
ws.Range("F2").FormulaR1C1 = "=SUM(C[-1])"
ws.Range("F1").FormulaR1C1 = "Total Hours"
ws.Range("G1").Select
Next ws
End Sub