Question: Sub euclid() Dim rCities As Range, rCity As Range Dim iRowCC As Integer, dEuclid() As Double, dDist As Double Dim i As Integer, j As

Sub euclid() Dim rCities As Range, rCity As Range Dim iRowCC As Integer, dEuclid() As Double, dDist As Double Dim i As Integer, j As Integer Set rCities = Range(Range("A3"), Range("A3").End(xlDown)) ReDim dEuclid(1 To rCities.Count, 1 To rCities.Count) iRowCC = 2 j = 1 Do Until IsEmpty(Cells(iRowCC, 1)) i = 1 For Each rCity In cities dDist = Sqr((rCity.Offset(0, 1) - Cells(iRowCC, 2)) ^ 2 + (rCity.Offset(0, 2) - Cells(iRowCC, 3)) ^ 2) dEuclid(i, j) = dDist i = i + 1 Next rCity j = j + 1 iRowCC = iRowCC + 1 Loop Range("G3").Resize(UBound(dEuclid, 1), UBound(dEuclid, 2)) = dEuclid End Sub

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!