|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 打印单据()
With Sheets("出库单")
r = .Cells(Rows.Count, 7).End(xlUp).Row
If r < 9 Then MsgBox "出库单为空,请先录入数据!": End
If Trim(.[i3]) = "" Then
.[i3] = Format(Date, "yyyymm") & Format(1, "000")
Else
yf = Val(Month(Date))
yf_1 = Val(Mid(Trim(.[i3]), 5, 2))
If yf <> yf_1 Then
.[i3] = Format(Date, "yyyymm") & Format(1, "000")
Else
.[i3] = Format(Date, "yyyymm") & Format(Val(Right(Trim(.[i3]), 3)) + 1, "000")
End If
End If
.PrintOut
End With
MsgBox "ok!"
End Sub
Sub baocun()
Dim arr()
Dim ar As Variant
With Sheets("出库单")
r = .Cells(Rows.Count, 7).End(xlUp).Row
If r < 9 Then MsgBox "出库单为空,请先录入数据!": End
ar = .Range("a3:i20")
ReDim arr(1 To UBound(ar), 1 To 14)
For i = 7 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
n = n + 1
arr(n, 1) = ar(1, 9)
arr(n, 2) = ar(2, 3)
arr(n, 3) = ar(3, 3)
arr(n, 4) = ar(4, 3)
For j = 2 To 9
arr(n, j + 3) = ar(i, j)
Next j
arr(n, 13) = .Cells(23, 3)
arr(n, 14) = .Cells(23, 5)
End If
Next i
End With
With Sheets("出库统计表")
rs = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(rs, 1).Resize(n, UBound(arr, 2)) = arr
.Cells(rs, 1).Resize(n, UBound(arr, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
|