Peter Davison
Active Member
- Joined
- Jun 4, 2020
- Messages
- 444
- Office Version
- 365
- Platform
- Windows
I am creating some rectangles in excel with the code below.
I have set it to create 5 rectangles using i = 0 to 4
What I am not sure is how I get the first block to start at 405 position and not 0 which is what "i" is starting at (I think).
Any help would be great.
Private Sub CommandButton1_Click()
Dim s As Shape
Dim i As Integer
Dim sleft As Integer
Const sWidth As Integer = 100
Const sHeight As Integer = 200
Dim ws As Worksheet
Set ws = Sheets("sheet1")
For i = 0 To 4
sleft = i * sWidth
'add a shape
'Positions (type of shape, Start Position from left, Start Position from Top, Width, Height)
Set s = ws.Shapes.AddShape(1, sleft, 130, sWidth, sHeight)
Next i
'make the fixture Black
s.Fill.ForeColor.RGB = RGB(0, 0, 0)
s.Fill.Visible = False
End Sub
I have set it to create 5 rectangles using i = 0 to 4
What I am not sure is how I get the first block to start at 405 position and not 0 which is what "i" is starting at (I think).
Any help would be great.
Private Sub CommandButton1_Click()
Dim s As Shape
Dim i As Integer
Dim sleft As Integer
Const sWidth As Integer = 100
Const sHeight As Integer = 200
Dim ws As Worksheet
Set ws = Sheets("sheet1")
For i = 0 To 4
sleft = i * sWidth
'add a shape
'Positions (type of shape, Start Position from left, Start Position from Top, Width, Height)
Set s = ws.Shapes.AddShape(1, sleft, 130, sWidth, sHeight)
Next i
'make the fixture Black
s.Fill.ForeColor.RGB = RGB(0, 0, 0)
s.Fill.Visible = False
End Sub