123

看板 Test
作者 Qoo20811 (冠宇哥)
時間 2024-05-28 14:27:40
留言 0則留言 (0推 0噓 0→)

Sub CalculateDifferences() Dim wsSource As Worksheet Dim wsDest As Worksheet Dim startRow As Long, endRow As Long, colStart As Long, colEnd As Long Dim i As Long, j As Long, k As Long Dim diffCount As Long ' 設置分頁 Set wsSource = Worksheets("Table") Set wsDest = Worksheets("AAA") ' 初始化參數 startRow = 2 ' 起始行 colStart = 5 ' 起始列 (E列) colEnd = 260 ' 結束列 (IZ列) diffCount = 0 ' 遍歷每組數據 For i = 0 To 63 endRow = startRow + 29 ' 每組數據30行 ' 遍歷每一列 For j = colStart To colEnd ' 遍歷每一行,從第二行開始計算差值 For k = startRow + 1 To endRow If wsSource.Cells(k, j).Value - wsSource.Cells(k - 1, j).Value < -3 Then diffCount = diffCount + 1 End If Next k Next j startRow = endRow + 1 ' 下一組數據的起始行 Next i ' 將結果顯示在分頁 "AAA" 的 S3 儲存格 wsDest.Range("S3").Value = diffCount End Sub --
※ 批踢踢實業坊(ptt.cc), 來自: 223.141.252.228 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Test/M.1716877662.A.53D.html

您可能感興趣