As
@Norie stated, it will be complicated to identify every cell which is lying inside the freeform shape outline
But here is something to get you started if that is what you need to do
Please post your final code here if you manage to solve the puzzle
To test
- create a NEW workbook
- insert the code in a module
- insert a freeform shape in Sheet1
- run the code
- a sheet is added by VBA listing the
x and
y co-ordinates of each point
- the unit values match those returned by Range("A1").Left, Range("A1").Top etc
VBA Code:
Sub ShapeNode_CoOrds()
Dim i As Long, shp As Shape, shpNode As ShapeNode, x As Double, y As Double, ws As Worksheet
With ActiveSheet
Set shp = .Shapes(1)
Set ws = Sheets.Add
ws.Columns("A:C").ColumnWidth = 15
For i = 1 To shp.Nodes.Count
Set shpNode = shp.Nodes.Item(i)
x = shpNode.Points(1, 1)
y = shpNode.Points(1, 2)
ws.Cells(i, 1).Resize(, 3) = Array(i, x, y)
Next i
End With
End Sub
Question
- why are you using a freeform shape for this when you could simply click on outline cells and then infill
- consider using ... Selection_Change, BeforeDoubleClick, BeforeRightClick events