本帖最後由 color790 於 2010-8-17 00:01 編輯
1.當B欄這一行由正轉負且絕對值大於5(ex. abs(B10-B9) = 6)
2.當負值開始變大時(ex. B13)
3.對應到A欄 步驟1 - 步驟2 (ex. C10= A10-A13)
4. 則為上面步驟相反(當B欄這一行由負轉正且絕對值大於5(ex.B15)--->正值開始變小(ex. B19)--->對應到A欄 步驟2 - 步驟1(ex. C19 - C15)
以下是我寫的,也是無法執行,可以幫我修改一下嗎?
Sub bbb()
For i = 3 To Worksheets("sheet1").Range("A1").End(xlDown).Row
j = i + 1
If Cells(i - 1, 2) < 0 And Cells(i, 2) > 0 And Abs(Cells(i - 1, 2) - Cells(i, 2)) > 5 Then
Do Until Cells(j, 2) < Cells(i, 2)
Cells(i, 3) = Cells(j, 1) - Cells(i, 1)
Else
If Cells(i - 1, 2) > 0 And Cells(i, 2) < 0 And Abs(Cells(i, 2) - Cells(i - 1, 2)) > 5 Then
Do Until Cells(j, 2) >Cells(i, 2)
Cells(i, 3) = Cells(i, 1) - Cells(j, 1)
End If
End If
Next
End Sub |