返回列表 上一主題 發帖

[發問] 求高手解惑

[發問] 求高手解惑

各位好,目前遇到很大的問題是...
我想把Roll那欄的數值,  自動挑出   ''數值大於五 且 連續20秒以上( C 欄為時間 )'',然後貼到另一工作表,請問該怎麼做呢?  

(附件,shee1為原始資料,  要變成像sheet2那樣)

ROLL.zip (360.35 KB)


因為用我目前的方式真的要挑很久...

謝謝大家幫幫我吧><!!

忘了說明,   C欄是時間 (8秒記錄一次),所以大概就是  連續四個儲存格

TOP

回復 2# gagashe

因每筆時間皆為8秒,所以不已時間做判斷,直接已連續4筆資料做判斷>20秒
Sub ex()
Dim R As Long, Cmax As Integer
Sheets("Sheet2").Range("A1").CurrentRegion.Delete
Sheets("Sheet1").Range("a2:t3").Copy Sheets("Sheet2").Range("a1")
With Sheets("Sheet1").Range("A1").CurrentRegion
   R = 4
   Do While R <= .Rows.Count
      Cmax = 0
      Do While .Cells(R + Cmax, 17) > 5 And .Cells(R + Cmax, 17) <> ""
         Cmax = Cmax + 1
      Loop
      If Cmax >= 4 Then Sheets("sheet1").Range(Cells(R, 1), Cells((R + Cmax - 1), 20)).Copy Sheets("Sheet2").Range("b65536").End(xlUp).Offset(1, -1)
      R = R + 1 + Cmax
   Loop
End With
End Sub

TOP

        靜思自在 : 並非有錢魷是快樂,問心無愧心最安。
返回列表 上一主題