Sub check()
Dim row As Long
Dim check As Long
Dim checknum As Long
Dim thisws As Worksheet
Set thisws = ActiveSheet //激活当前excel表格
row = thisws.UsedRange.Rows.Count
MsgBox "excel表共有行数" & row
check = 0
For i = 1 To row Step 1
If thisws.Cells(i, 3) = 0 Then
check = 0
End If
checknum = thisws.Cells(i, 3) //检查第3列数据
If check <> checknum Then
MsgBox "检查数据不一致" & i
End If
check = check + 1
Next
MsgBox "检查excel表完成,共有" & i & "满足要求"
End Sub
工作记录!
说明:作用是检查excel的第3列数据,从0开始递增,当遇到0时,又从零开始循环递增。用于检查数据。可以显示excel的总行数,显示不满足要求的行数。