My apologies. For some reason the forum always combines procedure declaration and first line of code when pasting and I forgot to fix (if I could still edit that post, I would).
New error is probably because missing PtInPoly() function. That code comes from item 3 referenced site. But I will show it here:
Code:
Public Function PtInPoly(Xcoord As Double, Ycoord As Double, Polygon As Variant) As Variant
Dim x As Long, NumSidesCrossed As Long, m As Double, b As Double, Poly As Variant
Poly = Polygon
For x = LBound(Poly) To UBound(Poly) - 1
If Poly(x, 0) > Xcoord Xor Poly(x + 1, 0) > Xcoord Then
m = (Poly(x + 1, 1) - Poly(x, 1)) / (Poly(x + 1, 0) - Poly(x, 0))
b = (Poly(x, 1) * Poly(x + 1, 0) - Poly(x, 0) * Poly(x + 1, 1)) / (Poly(x + 1, 0) - Poly(x, 0))
If m * Xcoord + b > Ycoord Then NumSidesCrossed = NumSidesCrossed + 1
End If
Next
PtInPoly = CBool(NumSidesCrossed Mod 2)
End Function
Every module should have Option Explicit in header. Can set VBA properties to do this automatically for new modules. Will have to manually add to existing.