返回列表 上一主題 發帖

excel多個量測正弦波型自動切分

回復 1# m06o2
  1. Sub test()
  2.    
  3. Dim LastRow As Long
  4. Sheets("工作表2").Cells.Clear
  5. With Sheets("工作表1")
  6.     LastRow = .Range("A1").CurrentRegion.Rows.Count
  7.     rr = 1
  8.     cc = 1
  9.     For i = 1 To LastRow
  10.         Sheets("工作表2").Cells(rr, cc) = .Cells(i, 1)
  11.         If i = LastRow Then Exit For
  12.         rr = rr + 1
  13.         If Sgn(0 - .Cells(i, 1)) + Sgn(0 - .Cells(i + 1, 1)) = 0 Then
  14.             aa = aa + 1
  15.             If aa Mod 2 = 1 Then
  16.             rr = 1
  17.             cc = cc + 1
  18.             End If
  19.         End If
  20.     Next i

  21. End With

  22. End Sub
複製代碼

TOP

        靜思自在 : 口說好話、心想好意、身行好事。
返回列表 上一主題