我有一个包含多个工作表的工作簿,我经常需要在所有工作簿的相同位置添加几行(所有工作表都具有相似的格式)。添加行很容易,因为我可以选择多个工作表但是我还需要对行进行分组,但在选择多个工作表时分组不起作用。到目前为止我的代码只对第一张表进行分组,尽管选择了所有代码。
Sub Group_Rows()
Dim myarray As Variant
myarray = Array("Net Rev", "PAP", "EST", "DLC", "COP", "CPPF", "Fixed Expenses", "OI", "Int HO by title",)
ThisWorkbook.Sheets(Array("Net Rev", "PAP", "EST", "DLC", "COP", "CPPF", "Fixed Expenses", "OI", "Int HO by title")).Select
Rows("50:50").Group
End Sub
非常感谢任何指导。 感谢
答案 0 :(得分:0)
我真的不明白为什么要对一行进行分组,但这里的代码就是这样......
Sub Group_Rows()
Dim myArray() As String, wsName As Variant
myArray = Split("Net Rev, PAP, EST, DLC, COP, CPPF, Fixed Expenses, OI, Int HO by title", ", ")
For Each wsName In myArray
ThisWorkbook.Sheets(wsName).Rows(50).Group
Next wsName
End Sub