This could be one way to shorten it
Code:Sub SubTotalize() Dim var, strarrSheetNames() As String strarrSheetNames = Split("XFLOW A,XFLOW B,XFLOW C", ",") For Each var In strarrSheetNames With Sheets(var) .Unprotect Password:="abc" .Range("B3:H" & .Cells(Rows.Count, 2).End(xlUp).Row).Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2, 3, 7), Replace:=True, PageBreaks:=False, SummaryBelowData:=True .Protect UserInterfaceOnly:=True, Password:="abc" End With Next var End Sub




Reply With Quote
Bookmarks