我想在工作簿中的所有工作表上重复此代码。循环遍历工作簿中的所有工作表
有时可能有1-2个工作表,有时50+。
Sub HoursTotal()
'
' HoursTotal Macro
'
Range("F2").Select
ActiveCell.FormulaR1C1 = "=SUM(C[-1])"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Total Hours"
Range("G1").Select
End Sub
欢迎来到SO!为了帮助你的代码,尽量避免使用'.Select'。它会让你的代码运行得慢一点。你可以从[This Question]中找到更多关于它的信息(http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros)。 – PartyHatPanda