Rick it is your code that I used when I searched in the Google group 3
days ago. I am delighted that you responded
About two years ago, I moved my online volunteering over from the compiled
VB newsgroups to the Excel newsgroups which is why I saw your question. I
pretty much always remember the larger code procedures I develop, so I
recognized the AreaByCoordinates function the instant I saw it.
What I do is (shortly) the following. I receive PDF files of drawings
from Architects. I then insert the PDF drawing onto an Excel Sheet and
measure floor areas, wall lengths, etc. for costing purposes. (At least
that is the intention) Accuracy is quite acceptable. So, the "polygon"
is actually a floor area of varying shapes(curved lines excluded)
My X coordinates are pasted to cells AD 5 downwards, and the Y
coordinates are pasted AE5 downwards. Hence the Range of AD5:AE5
Maybe I should have mentioned that earlier. The "lineal" measuring works
well, its only the area that's a problem.
<<<< Combined from your follow-up posting
Just spotted a mistake. The range should begin at cell AD5 (X
coordinate) and end at AE ?? Y coordinate- whatever the number
of Nodes there were, clicked sequentially clockwise.
Okay, in place of your Area subroutine, give this one a try...
Sub Area()
Dim X As Long
Dim Xcoord() As Double
Dim Ycoord() As Double
Const StartRow As Long = 5
Const StartCol As String = "AD"
Const AreaOutputAddress As String = "A5"
Dim LastRow As Long
With Worksheets("Sheet7")
LastRow = .Cells(Rows.Count, StartCol).End(xlUp).Row
ReDim Xcoord(0 To LastRow - StartRow)
ReDim Ycoord(0 To LastRow - StartRow)
For X = 0 To LastRow - StartRow
Xcoord(X) = .Cells(StartRow, StartCol).Offset(X, 0).Value
Ycoord(X) = .Cells(StartRow, StartCol).Offset(X, 1).Value
Next
.Range(AreaOutputAddress).Value = AreaByCoordinates(Xcoord(), Ycoord())
End With
End Sub
One final note. I see I omitted two Dim statements from my AreaByCoordinates
function. Please add these to the rest of the Dim statements...
Dim X As Double
Dim Y As Double
Rick