アプリ版:「スタンプのみでお礼する」機能のリリースについて

VBAの指示の内容
昨日こちらでご教示頂いたのですが初心者な為、一つ一つの指示が何をやっているのかわかっておらず、勉強の為ご教示いただきたく。

一つ一つの指示が何をやっているのかご教示よろしくお願い致します。

Option Explicit

Public Sub ユークリッド距離順()
Const BA1 As Long = 1000 '表縦の倍率
Const BA2 As Long = 100 '表横の倍率
Const BA3 As Long = 10 '表高の倍率
Const BA4 As Long = 1000 '裏縦の倍率
Const BA5 As Long = 100 '裏横の倍率
Const BA6 As Long = 10 '裏高の倍率
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim dicT As Object
Dim maxrow1 As Long
Dim namerow As Long
Dim wrow As Long
Dim row2 As Long
Dim name As String

Dim d1 As Long, d2 As Long, d11 As Long, d12 As Long, d13 As Long, d21 As Long, d22 As Long, d23 As Long
Set dicT = CreateObject("Scripting.Dictionary") ' 連想配列の定義
Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")
maxrow1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row 'sheet1 最終行を求める
If maxrow1 < 4 Then Exit Sub
name = sh2.Range("B1").Value
If name = "" Then Exit Sub
sh2.Rows("5:" & Rows.Count).ClearContents '5行目以降クリア
namerow = 0
For wrow = 3 To maxrow1
If name = sh1.Cells(wrow, 1).Value Then
namerow = wrow
End If
Next
If namerow = 0 Then
MsgBox (name & "が存在しません")
Exit Sub
End If
'ユークリッド距離の計算
row2 = 5
For wrow = 3 To maxrow1
If wrow <> namerow Then
sh2.Cells(row2, 1).Value = sh1.Cells(wrow, 1).Value '表名前
sh2.Cells(row2, 4).Value = sh1.Cells(wrow, 1).Value '裏名前
d11 = (sh1.Cells(wrow, 2).Value - sh1.Cells(namerow, 2).Value)
d12 = (sh1.Cells(wrow, 3).Value - sh1.Cells(namerow, 3).Value)
d13 = (sh1.Cells(wrow, 4).Value - sh1.Cells(namerow, 4).Value)
d21 = (sh1.Cells(wrow, 5).Value - sh1.Cells(namerow, 5).Value)
d22 = (sh1.Cells(wrow, 6).Value - sh1.Cells(namerow, 6).Value)
d23 = (sh1.Cells(wrow, 7).Value - sh1.Cells(namerow, 7).Value)
d1 = d11 * d11 * BA1 + d12 * d12 * BA2 + d13 * d13 * BA3
d2 = d21 * d21 * BA4 + d22 * d22 * BA5 + d23 * d23 * BA6
sh2.Cells(row2, 2).Value = d1 '表距離
sh2.Cells(row2, 5).Value = d2 '裏距離
row2 = row2 + 1
End If
Next
'ソート
sh2.Range("A5:B" & row2 - 1).Sort key1:=sh2.Range("B5"), Order1:=xlAscending, Header:=xlNo
sh2.Range("D5:E" & row2 - 1).Sort key1:=sh2.Range("E5"), Order1:=xlAscending, Header:=xlNo
sh2.Rows("10:" & Rows.Count).ClearContents '10行目以降クリア
MsgBox ("完了")
End Sub

A 回答 (2件)

前回回答者です。


コメントを付加したものを下記にアップしました。
不明点があれば、補足してください。
https://ideone.com/9b8d2M
    • good
    • 0
この回答へのお礼

ありがとうございます。
勉強させていただきます。

お礼日時:2022/10/25 19:30

だいたい『気をつけ』と同じ意味ですが、時々思い出したように『休め』が入っています。



最後の1行は『前へならえ』になっていて、これは腕がだるくなるバグと思います。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!