|
rivate Sub Worksheet_Activate()
Dim ARR, BRR, CRR, W%, I%, J%, t
' On Error GoTo 10
ActiveSheet.Unprotect
Sheets("库存表").Range("A4:N" & Sheets("库存表").Range("A65536").End(3).Row + 2).ClearContents
ARR = Sheets("基础信息表").Range("A2:G" & Sheets("基础信息表").Range("A65536").End(3).Row)
W = UBound(ARR)
ReDim BRR(1 To W, 1 To 14)
For I = 1 To W
For J = 1 To 5
BRR(I, J) = ARR(I, J)
Next
BRR(I, 6) = ARR(I, 5) * ARR(I, 6)
Next
CRR = Sheets("数据库").Range("E2:N" & Sheets("数据库").Range("E65536").End(3).Row)
For I = 1 To UBound(CRR)
For J = 1 To W
If CRR(I, 1) = BRR(J, 1) Then
BRR(J, 7) = BRR(J, 7) + CRR(I, 5)
BRR(J, 8) = BRR(J, 8) + CRR(I, 7)
BRR(J, 9) = BRR(J, 9) + CRR(I, 8)
BRR(J, 10) = BRR(J, 10) + CRR(I, 10)
End If
Next
Next
For I = 1 To W
BRR(I, 11) = BRR(I, 5) + BRR(I, 7) - BRR(I, 9)
BRR(I, 12) = BRR(I, 6) + BRR(I, 8) - BRR(I, 10)
If BRR(I, 11) <> 0 Then BRR(I, 13) = Format(BRR(I, 12) / BRR(I, 11), "0.00")
Next
For I = 1 To UBound(BRR)
For J = 1 To UBound(ARR)
If ARR(J, 1) = BRR(I, 1) And BRR(I, 11) < ARR(J, 7) Then BRR(I, 14) = "低库存": Exit For
Next
t = t + BRR(I, 12)
Next
Range("N3:N" & Range("A65536").End(3).Row).AutoFilter
Range("A4").Resize(W, 14) = BRR
Range("M1") = t
Range("N3:N" & Range("A65536").End(3).Row).AutoFilter
10 ActiveSheet.Protect AllowFiltering:=True
End Sub
这一句 BRR(I, 6) = ARR(I, 5) * ARR(I, 6) (显示为黄色)
1、我把编码改成了1001 这样的编码,录入数据后按库存表,显示不出来,然后VBA弹出这个出来
2、单据录入里的表头为《物资出库单》怎么才能改为自己的加上***公司出库单这样的表头呢
3、单据录入里的打印可以添加一个全选么?
4、可以在库存明细里添加一个像单据录入里的批量打印的功能吗? |
|