Hello all.
I have a workbook with over 20 tabs. I am trying to build a VBA code that it goes through all 19 tabs inserts rows creates a table inserts a slicer.
The tables consist of the same columns but the rows will vary. Slicer is always the same. Also, i have a Summary sheet that does not need a table.
Any direction would be helpful.
I have a workbook with over 20 tabs. I am trying to build a VBA code that it goes through all 19 tabs inserts rows creates a table inserts a slicer.
The tables consist of the same columns but the rows will vary. Slicer is always the same. Also, i have a Summary sheet that does not need a table.
Any direction would be helpful.
VBA Code:
Sub Macro1()
'''''''' inserts rows
Rows("1:13").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'''''''' inserts Table
Range("A14").Select
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$14:$N$3799"), , xlYes).Name _ '''Rows vary
= "Table1"
'''''''' Adds slicer Always same
Range("Table1[#All]").Select
ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.ListObjects("Table1"), "Group"). _
Slicers.Add ActiveSheet, , "Group", "Group", 366, 639.75, 144, 190
ActiveSheet.Shapes.Range(Array("Group")).Select
'''''''' Positions slicer
ActiveSheet.Shapes("Group").IncrementLeft -12 ''' Positioning in cell A1
ActiveSheet.Shapes("Group").IncrementTop -12 ''' Positioning in cell A1
Range("Table1[[#Headers],[Supplier]]").Select
End Sub