0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vbn

Last updated at Posted at 2023-10-30

Do While keyBaseRow <= UBound(keyData, 1)
' すでに合計が計算されたkeyはスキップ
If IsEmpty(keyData(keyBaseRow, 1)) Then
Dim groupSumValue As Long
groupSumValue = rowSum(keyBaseRow)

    keyChkRow = keyBaseRow + 1 ' keyBaseRowより次の行から比較を開始

    ' まず、合計値を計算
    Do While keyChkRow <= UBound(keyData, 1)
        If keyData(keyBaseRow, 0) = keyData(keyChkRow, 0) Then
            groupSumValue = groupSumValue + rowSum(keyChkRow)
        End If
        keyChkRow = keyChkRow + 1
    Loop

    ' 次に、一致する全ての行に合計値を保存
    keyChkRow = keyBaseRow ' keyBaseRowより次の行から比較を開始
    Do While keyChkRow <= UBound(keyData, 1)
        If keyData(keyBaseRow, 0) = keyData(keyChkRow, 0) Then
            keyData(keyChkRow, 1) = groupSumValue
        End If
        keyChkRow = keyChkRow + 1
    Loop

    ' keyBaseRow行目にも合計値を保存
    keyData(keyBaseRow, 1) = groupSumValue
End If
keyBaseRow = keyBaseRow + 1

Loop

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?