You can create rectangles with the .addshape method. For simplicity, I created a macro called test():
Cited from https://learn.microsoft.com/en-us/office/vba/api/excel.shapes.addshape
Set myDocument = Worksheets(1)
myDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
---------------------------------
If this is helpful please accept answer.