UT804数据秒数据提取

UT804的接收软件接收的默认不是整秒接收。下面的代码提取了整秒的数据以方便统计。

代码如下

Sub Macro1()

    '关闭屏幕更新
    Application.ScreenUpdating = False
    
    Dim i As Long
    Dim hang As Long
    hang = 1
    Dim tmp  As String
    Dim tmp2 As String
    With Sheet2
        '首行数据处理
        hang = 1
        i = 1
        .Cells(hang, 10) = .Cells(i, 1)
        .Cells(hang, 11) = .Cells(i, 2)
        .Cells(hang, 12) = .Cells(i, 3)
        .Cells(hang, 13) = .Cells(i, 4)
        .Cells(hang, 14) = .Cells(i, 5)
        .Cells(hang, 15) = .Cells(i, 6)
        .Cells(hang, 16) = .Cells(i, 7)
        .Cells(hang, 17) = .Cells(i, 8)
        hang = 1
        
        '处理60000行数据
        For i = 2 To 60000
            tmp = .Cells(i - 1, 2)
            tmp2 = .Cells(i, 2)
            If tmp <> tmp2 Then
                hang = hang + 1
            End If
            If Len(tmp2) <= 0 Then ’结束判断
                Exit For
            End If
            .Cells(hang, 10) = .Cells(i, 1)
            .Cells(hang, 11) = .Cells(i, 2)
            .Cells(hang, 12) = .Cells(i, 3)
            .Cells(hang, 13) = .Cells(i, 4)
            .Cells(hang, 14) = .Cells(i, 5)
            .Cells(hang, 15) = .Cells(i, 6)
            .Cells(hang, 16) = .Cells(i, 7)
            .Cells(hang, 17) = .Cells(i, 8)
            
        Next i        
    End With
    '打开屏幕更新
    Application.ScreenUpdating = True
End Sub

特此记录

anlog

2023年9月27日

你可能感兴趣的:(笔记,vba,ut804)