|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim r, i, x, arr, brr()
Dim dh, lx, rq
With Sheet27
dh = .[i3]
lx = .[c3]
rq = .[e3]
If IsNumeric(dh) = False Or Sheet27.[i3] = "" Then MsgBox "单号错误": Exit Sub
If lx = "" Or rq = "" Then MsgBox "类型和发货日期不能为空": Exit Sub
With Sheets("国润发货汇总")
r = .Cells(.Rows.Count, 1).End(3).Row
arr = .Range("A3:K" & r)
End With
ReDim brr(1 To UBound(arr), 1 To 5)
For i = 3 To UBound(arr)
If VBA.Trim(arr(i, 3)) <> "" Then
If IsDate(arr(i, 3)) Then
If arr(i, 2) = dh And arr(i, 3) = rq And arr(i, 5) = lx Then
x = x + 1
brr(x, 1) = x
brr(x, 2) = arr(i, 6)
brr(x, 3) = arr(i, 7)
brr(x, 4) = arr(i, 8)
brr(x, 5) = arr(i, 11)
End If
End If
End If
Next i
.[a5:e27].ClearContents
If x = "" Then MsgBox "没有符合条件的数据!": End
.[a5].Resize(x, UBound(brr, 2)) = brr
End With
Application.ScreenUpdating = True
End Sub
|
|