Roxanne8912
New Member
- Joined
- Jun 29, 2018
- Messages
- 4
Hello,
Does anyone have VBA code whichselects all shapes in a workbook and then sizes them the same height and width(1 in X 1in). The shapes are embeddedDocuments and Packager Shell Object
Below is code where I am splitting atable into multiple sheets. The splitworks great with one exception. Theshapes do not copy over as the same size and they will stack in the first rowof the new sheet. I have solved for the stacking issue but cannot seem tosize the shapes.
Any help would be appreciated.
'Split table
Set asheet= ActiveSheet
lastrow =asheet.Range("A" & Rows.Count).End(xlUp).Row
myarray =uniqueValues(asheet.Range("A2:A" & lastrow))
Dim Sh AsShape
For i =LBound(myarray) To UBound(myarray)
Sheets.Add.Name = myarray(i)
asheet.Range("A1:AE" & lastrow).AutoFilter Field:=1,Criteria1:=myarray(i)
asheet.Range("A1:AE" &lastrow).SpecialCells(xlCellTypeVisible).Copy _
Sheets(myarray(i)).Range("A1:AE1")
asheet.Range("A1:AE" & lastrow).AutoFilter
' Remove shapes from header row (Previous rowcarries over as a thin line stored in header row)
Dim ShpAs Shape
Dim rAs Range
Set r =Range("A1:AE1")
ForEach Shp In ActiveSheet.Shapes
If Not Intersect(Range(Shp.TopLeftCell, Shp.BottomRightCell), r) IsNothing Then _
Shp.Delete
Next Shp
' Resizesshapes
DimShp2 As Shape
Dim r2As Range
Setr2 = Range("A1:AE" & lastrow)
ForEach Shp2 In ActiveSheet.Shapes
If Not Intersect(Range(Shp2.TopLeftCell, Shp2.BottomRightCell), r) IsNothing Then _
Shp2.Width = 35
Shp2.Height = 35
Next Shp2
Next i
Does anyone have VBA code whichselects all shapes in a workbook and then sizes them the same height and width(1 in X 1in). The shapes are embeddedDocuments and Packager Shell Object
Below is code where I am splitting atable into multiple sheets. The splitworks great with one exception. Theshapes do not copy over as the same size and they will stack in the first rowof the new sheet. I have solved for the stacking issue but cannot seem tosize the shapes.
Any help would be appreciated.
'Split table
Set asheet= ActiveSheet
lastrow =asheet.Range("A" & Rows.Count).End(xlUp).Row
myarray =uniqueValues(asheet.Range("A2:A" & lastrow))
Dim Sh AsShape
For i =LBound(myarray) To UBound(myarray)
Sheets.Add.Name = myarray(i)
asheet.Range("A1:AE" & lastrow).AutoFilter Field:=1,Criteria1:=myarray(i)
asheet.Range("A1:AE" &lastrow).SpecialCells(xlCellTypeVisible).Copy _
Sheets(myarray(i)).Range("A1:AE1")
asheet.Range("A1:AE" & lastrow).AutoFilter
' Remove shapes from header row (Previous rowcarries over as a thin line stored in header row)
Dim ShpAs Shape
Dim rAs Range
Set r =Range("A1:AE1")
ForEach Shp In ActiveSheet.Shapes
If Not Intersect(Range(Shp.TopLeftCell, Shp.BottomRightCell), r) IsNothing Then _
Shp.Delete
Next Shp
' Resizesshapes
DimShp2 As Shape
Dim r2As Range
Setr2 = Range("A1:AE" & lastrow)
ForEach Shp2 In ActiveSheet.Shapes
If Not Intersect(Range(Shp2.TopLeftCell, Shp2.BottomRightCell), r) IsNothing Then _
Shp2.Width = 35
Shp2.Height = 35
Next Shp2
Next i