|
Private Sub CommandButton1_Click()
Range("A26:T58").ClearContents
If [R2] < " " Then Exit Sub
With Sheets("质量情况汇总")
Set rg = .Columns(1).Find([R2], lookat:=xlWhole)
If rg Is Nothing Then MsgBox "没有不合格品": Exit Sub
r = rg.Row
i = 26
Do
Range("A" & i) = .Range("B" & r) '时间
Range("C" & i) = .Range("C" & r) 'BANZU
Range("D" & i) = .Range("E" & r) '设备
Range("E" & i) = .Range("F" & r) '牌号
Range("H" & i) = .Range("G" & r) '批号
Range("J" & i) = .Range("H" & r) '不合格现象
Range("L" & i) = .Range("I" & r) '类型
Range("M" & i) = .Range("J" & r) '不合格原因
Range("Q" & i) = .Range("K" & r) '不合格量
Range("R" & i) = .Range("L" & r) '单位
Range("S" & i) = .Range("M" & r) '不合格处置
i = i + 1
r = r + 1
Loop While Val(.Range("A" & r)) = Val([R2])
End With
CommandButton1.Enabled = True
End Sub
一个筛选程序,运行到 Loop While Val(.Range("A" & r)) = Val([R2])时中显示“错误16”,该怎样改?
谢谢
|
|