Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
If the cells in a workshset are square (say 1 cm width and height) what is
the easiest way to calculate the distance between the center of one cell and the center of another? -- Gary's Student |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
Use Pythagoras: a^2+b^2 = c^2, where a and b are the distances in rows and
columns -- Kind regards, Niek Otten "Gary''s Student" wrote in message ... If the cells in a workshset are square (say 1 cm width and height) what is the easiest way to calculate the distance between the center of one cell and the center of another? -- Gary's Student |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
Hi Gary's Student,
I tried Ken's code and it gave me 108.1873. Is that centimeters or what? I just tried it on a standard sheet, no cell resizing. Curious as to what you are applying this to. Regards, Howard "Gary''s Student" wrote in message ... If the cells in a workshset are square (say 1 cm width and height) what is the easiest way to calculate the distance between the center of one cell and the center of another? -- Gary's Student |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
Hi L. Howard Kittle,
measurements are in points (72 points per inch) Ken Johnson |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Distance between cells
Hi Howard,
The code does rely on all cells being square, otherwise value of c is incorrect. I too am a little curious as to Gary''s Student's application. Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deselect Cells while using ctrl | Excel Discussion (Misc queries) | |||
Condensing a list/range with blank cells to a new list/range without blanks | Excel Worksheet Functions | |||
Fill cells from non-adjacent cells | Excel Discussion (Misc queries) | |||
Help adding text values | Excel Worksheet Functions | |||
Convert data type of cells to Text,Number,Date and Time | Excel Worksheet Functions |