View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Distance between cells

Niek & Ken:
Thank you both.
--
Gary's Student


"Ken Johnson" wrote:

Hi Gary's Student,
the following gave me an accurate result for the straight distance
between the centres of A1 and G7:

Public Sub Line_Length()
Dim Rng1 As Range, Rng2 As Range, c As Single, Side As Single
Set Rng1 = ActiveSheet.Range("A1")
Set Rng2 = ActiveSheet.Range("G7")
Side = Rng1.Height
c = Sqr(((Rng1.Row - Rng2.Row) * Side) ^ 2 + ((Rng1.Column -
Rng2.Column) * Side) ^ 2)
MsgBox c
End Sub

Ken Johnson