Vba add shape to worksheet in Excel

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub AddShapes()
  3. ''
  4. 'Add a Rectangle.
  5. ActiveSheet.Shapes.AddShape msoShapeRectangle, 20, 20, 50, 50
  6. ''
  7. 'Add a Rounded Rectangle.
  8. ActiveSheet.Shapes.AddShape msoShapeRoundedRectangle, 20, 120, 50, 50
  9. ''
  10. 'Add a 4-point star.
  11. ActiveSheet.Shapes.AddShape msoShape4pointStar, 20, 220, 50, 50
  12. ''
  13. End Sub

Description:

a) Line 5, 8, 11 - the 4 numbered arguments after the Shape type are as follows -

1) Position of Shape from Left Edge of the WorkSheet

2) Position of Shape from Top Edge of the WorkSheet

3) Shape Width

4) Shape Height

b) For getting supported Shape Types, consult MSDN, potential source -

Result after Macro execution:

excel vba add shape to worksheet

 

You can find similar Excel Questions and Answer hereunder

1) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

2) How do I update my DropDown list whenever the sheet is activated?

3) How do I enter a formula in a cell using VBA (using Relative Reference)?

4) How can I sort data using VBA?

5) How do I enter a formula in a cell using VBA (using Absolute Reference)?

6) How can I avoid updates to cell values during macro execution?

7) Want to use Microsoft Outlook in Excel. Here some basic explanation to get you started

8) How can I get row count of filtered data?

9) Determine if hyperlinks are valid in Excel

10) How can I hide Formula Bar and Headings using VBA?

 

Here the previous and next chapter