Distance between points - matrix

DrunkDuck

New Member
Joined
Aug 6, 2019
Messages
1
Hey,

i'm trying to make a table that looks like this:

BCDEFG

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]17[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]0[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]15[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]20[/TD]

[TD="align: center"]18[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]9.5[/TD]
[TD="align: right"]7.1[/TD]

[TD="align: center"]19[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]5[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]9.4[/TD]

[TD="align: center"]20[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]10[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]9.4[/TD]

[TD="align: center"]21[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]15[/TD]
[TD="align: right"]9.5[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]5.7[/TD]

[TD="align: center"]22[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]20[/TD]
[TD="align: right"]7.1[/TD]
[TD="align: right"]9.4[/TD]
[TD="align: right"]9.4[/TD]
[TD="align: right"]5.7[/TD]
[TD="align: right"]0[/TD]

</tbody>
Data

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C18[/TH]
[TD="align: left"]=SQRT(SUMSQ($C$12-C12,$C$13-C13,$C$14-C14,$C$15-C15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D18[/TH]
[TD="align: left"]=SQRT(SUMSQ($C$12-D12,$C$13-D13,$C$14-D14,$C$15-D15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E18[/TH]
[TD="align: left"]=SQRT(SUMSQ($C$12-E12,$C$13-E13,$C$14-E14,$C$15-E15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F18[/TH]
[TD="align: left"]=SQRT(SUMSQ($C$12-F12,$C$13-F13,$C$14-F14,$C$15-F15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G18[/TH]
[TD="align: left"]=SQRT(SUMSQ($C$12-G12,$C$13-G13,$C$14-G14,$C$15-G15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C19[/TH]
[TD="align: left"]=SQRT(SUMSQ($D$12-C12,$D$13-C13,$D$14-C14,$D$15-C15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D19[/TH]
[TD="align: left"]=SQRT(SUMSQ($D$12-D12,$D$13-D13,$D$14-D14,$D$15-D15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E19[/TH]
[TD="align: left"]=SQRT(SUMSQ($D$12-E12,$D$13-E13,$D$14-E14,$D$15-E15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F19[/TH]
[TD="align: left"]=SQRT(SUMSQ($D$12-F12,$D$13-F13,$D$14-F14,$D$15-F15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G19[/TH]
[TD="align: left"]=SQRT(SUMSQ($D$12-G12,$D$13-G13,$D$14-G14,$D$15-G15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C20[/TH]
[TD="align: left"]=SQRT(SUMSQ($E$12-C12,$E$13-C13,$E$14-C14,$E$15-C15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D20[/TH]
[TD="align: left"]=SQRT(SUMSQ($E$12-D12,$E$13-D13,$E$14-D14,$E$15-D15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E20[/TH]
[TD="align: left"]=SQRT(SUMSQ($E$12-E12,$E$13-E13,$E$14-E14,$E$15-E15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F20[/TH]
[TD="align: left"]=SQRT(SUMSQ($E$12-F12,$E$13-F13,$E$14-F14,$E$15-F15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G20[/TH]
[TD="align: left"]=SQRT(SUMSQ($E$12-G12,$E$13-G13,$E$14-G14,$E$15-G15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C21[/TH]
[TD="align: left"]=SQRT(SUMSQ($F$12-C12,$F$13-C13,$F$14-C14,$F$15-C15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D21[/TH]
[TD="align: left"]=SQRT(SUMSQ($F$12-D12,$F$13-D13,$F$14-D14,$F$15-D15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E21[/TH]
[TD="align: left"]=SQRT(SUMSQ($F$12-E12,$F$13-E13,$F$14-E14,$F$15-E15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F21[/TH]
[TD="align: left"]=SQRT(SUMSQ($F$12-F12,$F$13-F13,$F$14-F14,$F$15-F15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G21[/TH]
[TD="align: left"]=SQRT(SUMSQ($F$12-G12,$F$13-G13,$F$14-G14,$F$15-G15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C22[/TH]
[TD="align: left"]=SQRT(SUMSQ($G$12-C12,$G$13-C13,$G$14-C14,$G$15-C15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D22[/TH]
[TD="align: left"]=SQRT(SUMSQ($G$12-D12,$G$13-D13,$G$14-D14,$G$15-D15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E22[/TH]
[TD="align: left"]=SQRT(SUMSQ($G$12-E12,$G$13-E13,$G$14-E14,$G$15-E15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F22[/TH]
[TD="align: left"]=SQRT(SUMSQ($G$12-F12,$G$13-F13,$G$14-F14,$G$15-F15))[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G22[/TH]
[TD="align: left"]=SQRT(SUMSQ($G$12-G12,$G$13-G13,$G$14-G14,$G$15-G15))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



from this kind of data:

BCDEFG
a1
a2
a3
a4

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] , align: right"]tacts[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]0[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]15[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFF00]#FFFF00[/URL] "]20[/TD]

[TD="align: center"]11[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] "]criterium[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"][/TD]

[TD="align: center"]12[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]13[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]4[/TD]

[TD="align: center"]14[/TD]

[TD="align: right"]4[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]9[/TD]

[TD="align: center"]15[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]5[/TD]

</tbody>
Data



It's easy to set the formula in the left row with "$" to easily autofill to the right. Currently in the formula I have for example cell $C$12 that when going one cell down need to convert to $D$12.. I would be grateful for suggestions on possible changes to formula or a macro to be able to do this. I tried using macro with "Application.ConvertFormula" but i was able only to change every "$" in the cell but in this case it would need to be only specific ones.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to Mr Excel forum

Maybe something like this...


[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][td="bgcolor: #DCE6F1"]
G
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
10
[/td][td]
tacts​
[/td][td]
0​
[/td][td]
5​
[/td][td]
10​
[/td][td]
15​
[/td][td]
20​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
11
[/td][td]
criterium​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
12
[/td][td]
a1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
13
[/td][td]
a2​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
2​
[/td][td]
4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
14
[/td][td]
a3​
[/td][td]
4​
[/td][td]
1​
[/td][td]
1​
[/td][td]
7​
[/td][td]
9​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
15
[/td][td]
a4​
[/td][td]
1​
[/td][td]
1​
[/td][td]
1​
[/td][td]
10​
[/td][td]
5​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
16
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
17
[/td][td][/td][td]
0​
[/td][td]
5​
[/td][td]
10​
[/td][td]
15​
[/td][td]
20​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
18
[/td][td]
0​
[/td][td]
0,0​
[/td][td]
3,0​
[/td][td]
3,0​
[/td][td]
9,5​
[/td][td]
7,1​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
19
[/td][td]
5​
[/td][td]
3,0​
[/td][td]
0,0​
[/td][td]
0,0​
[/td][td]
10,9​
[/td][td]
9,4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
20
[/td][td]
10​
[/td][td]
3,0​
[/td][td]
0,0​
[/td][td]
0,0​
[/td][td]
10,9​
[/td][td]
9,4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
21
[/td][td]
15​
[/td][td]
9,5​
[/td][td]
10,9​
[/td][td]
10,9​
[/td][td]
0,0​
[/td][td]
5,7​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
22
[/td][td]
20​
[/td][td]
7,1​
[/td][td]
9,4​
[/td][td]
9,4​
[/td][td]
5,7​
[/td][td]
0,0​
[/td][/tr]
[/table]


Formula in C18 copied across and down
=SQRT(SUMSQ(INDEX(INDEX($C$12:$G$15,0,MATCH($B18,$C$10:$G$10,0))-INDEX($C$12:$G$15,0,MATCH(C$17,$C$10:$G$10,0)),)))

Format as Number wit 1 decimal place.

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top