Format the shapes

    Select the Rectangele shape

  • ActiveSheet.Shapes.Range(Array("Rectangle 1")).Select
  •  

    Add a rectangle shape and connect

  • ActiveSheet.Shapes.AddShape(msoShapeRectangle, 450, 204.75, 192, 77.25).Select
  •  

    Add a Straight Line and connect to Rectangle

    Range("F13").Select
    ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 131.25, 106.5, _ 316.8750393701, 170.25).Select
    Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
    Selection.ShapeRange.ConnectorFormat.BeginConnect ActiveSheet.Shapes( _ "Rectangle 3"), 3

     

    Ensure shape exists or not in a defined Range

    Sub Ensure_Shape_Exists_Or_Not_In_A_Defined_Range()
    Dim shp As Shape
    Dim Rng As Range

    Set r = Range("A1:H20")

    For Each shp In ActiveSheet.Shapes
    If Not Intersect(Range(shp.TopLeftCell, shp.BottomRightCell), Rng) Is Nothing Then
    shp.Select
    shp.Delete
    Next
    End Sub

     

    Find the top right cell address of the Rectangle

    Sub Find_The_Top_Right_Cell_Address_Of_Rectangle_Shape()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    Dim shap As Shape
    Set shap = sh.Shapes("Rect1")
    shap.Select
    Dim Rng As Range
    Set Rng = Cells(shap.TopLeftCell.Row, shap.BottomRightCell.Column)
    MsgBox Rng.Address
    End Sub

    Find Begin and End connected shape name

    Sub Find_Begin_Connected_Shape_Name_And_End_Connected_ShapeName()

    Dim ArrowConnector As Shape
    Dim shp As Shape

    For Each shp In ActiveSheet.Shapes
    MsgBox shp.Name

    If shp.Connector = True Then
    Set ArrowConnector = ActiveSheet.Shapes(shp.Name)
    MsgBox ArrowConnector.Name
    MsgBox ArrowConnector.ConnectorFormat.BeginConnectedShape.Name
    MsgBox ArrowConnector.ConnectorFormat.EndConnectedShape.Name
    If shp.ConnectorFormat.BeginConnectedShape.Name = "Rect 11" Then
    MsgBox "Identified the Shape"
    End If
    If InStr(ArrowConnector.ConnectorFormat.BeginConnectedShape.Name, "Rect") > 0 Then
    Exit For
    End If
    Exit For
    End If
    Next shp
    End Sub

    Move the shape from Left to Right:

    ActiveSheet.Shapes.Range(Array("Rect11")).Select Selection.ShapeRange.IncrementLeft 10 Selection.ShapeRange.IncrementTop 50