A spreadsheet has a selection of five countries on a map (shape on the spreadsheet.) On selection of a shape, data is calculated from inputs worksheet onto output worksheet.
I have a couple of queries :
1) where do the names "Rectangle" and "Freeform" come from as they are not defined anywhere.
2) also, what is the code referring to f.left, width etc doing?
Thanks in advance
I have a couple of queries :
1) where do the names "Rectangle" and "Freeform" come from as they are not defined anywhere.
2) also, what is the code referring to f.left, width etc doing?
Thanks in advance
Code:
Sub PopulateBoxes(display As Boolean)
Dim c As Variant
Dim f, r As Object
Dim i, j As Integer
Dim Groups() As String
Sheets("Display").Select
For Each r In ActiveSheet.Shapes()
If Left(r.Name, 9) = "Rectangle" Then
i = i + 1
r.Select
Selection.BringToFront
If display Then
Selection.Characters.Text = Range("AREAS_DISPLAY").Cells(i, 1).Value
Else:
Selection.Characters.Text = i
End If
For Each f In ActiveSheet.Shapes()
If Left(f.Name, 8) = "Freeform" And f.Left < r.Left And f.Left + f.Width > r.Left + r.Width _
And f.Top < r.Top And f.Top + f.Height > r.Top + r.Height Then
r.Left = f.Left + (f.Width - r.Width) / 2
End If
Next f
End If
Next r
Range("A1").Select
End Sub