1

I'm currently trying to auto name the objects from a referenced list rather than just have the object text stated in the script.

How do I get the script to reference a separate worksheet called Process Steps where the text value is in cell C7 instead of entering the statement in the script as Step 1

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 50, 50, 100, 50).Select
Selection.Formula = ""
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset40
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Step1"
Community
  • 1
  • 1
Adrian Gornall
  • 327
  • 5
  • 12
  • 28

1 Answers1

1

Peter has already mentioned how to pick up a value from another cell. Taking this a bit ahead.

Please avoid the use of .Select/.Activate INTERESTING READ

Is this what you are trying?

Sub Sample()
    Dim shp As Shape

    Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 50, 50, 100, 50)

    With shp.OLEFormat.Object
        .Formula = ""

        .ShapeRange.ShapeStyle = msoShapeStylePreset40

        .ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
        ThisWorkbook.Sheets("Process Steps").Range("C7").Value
    End With
End Sub
Community
  • 1
  • 1
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250