|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 生产单()
Dim arr As Variant, brr(), crr(), i&, j&, k&
s = [b3].Value
If Len(s) = 0 Then MsgBox "未输入订单号,无法查询": Exit Sub
arr = Sheets("录入数据").[a1].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To 6)
ReDim crr(1 To UBound(arr), 1 To 5)
For i = 1 To UBound(arr)
If arr(i, 3) = s Then
k = k + 1
If k = 1 Then [f3] = arr(i, 19)
brr(k, 1) = k
brr(k, 2) = arr(i, 5)
For j = 9 To 11
brr(k, j - 6) = arr(i, j)
Next j
brr(k, 6) = arr(i, 13)
For j = 25 To 29
crr(k, j - 24) = arr(i, j)
Next j
End If
Next
[a6:f16] = Empty
[b18:f22] = Empty
If k > 0 Then
[a6].Resize(k, 6) = brr
[b18].Resize(k, 5) = crr
Else
MsgBox "查无数据"
End If
End Sub |
|