|
如下入库信息和出库信息,后面的出库信息还没加上,可以随意添加,现在都是用测试数据
生成的出库单,有自动生成入库单号,每张出库单根据本图的“入库日期”和“供应商信息”查询上图明细表的第二列“日期”和“摘要”相匹配,打印某天此供应商的入库信息,并有生成入库单号,报表要打印。
C语言思维模式代码,,,:
Private Sub CommandButton1_Click()
Public Sht1 As Worksheet
Public Sht2 As Worksheet
Dim iNum As Integer
Dim jNum As Integer
Dim kNum As Integer
Set Sht1 = Sheets("材料出入库明细表201401-201509")
Set Sht2 = Sheets("出库单")
Sht1.Activate
Sht1.Range("a1").Select
iNum = Sht1.Range("S5").Select.Value
For jNum = 2 To iNum Step 1
For kNum = 2 To 6 Step 1
If [ Range("$B$"&jNum).Value = Sht2.Range(″A1″).Value And Range("$G$"&jNum).Value = Sht2.Range(″A1″).Value ] Then
Sht2.Activate
Range("A" & jNum + 3) = Sht1.Range("C" & jNum).Select.Value '物料编码
Range("B" & kNum + 3) = Sht1.Range("D" & jNum).Select.Value '品名
Range("C" & kNum + 3) = Sht1.Range("E" & jNum).Select.Value '规格型号
Range("D" & kNum + 3) = Sht1.Range("F" & jNum).Select.Value '单位
Range("E" & kNum + 3) = Sht1.Range("H" & jNum).Select.Value '数量
Range("F" & kNum + 3) = Sht1.Range("I" & jNum).Select.Value '不含税单价
Range("G" & kNum + 3) = Sht1.Range("J" & jNum).Select.Value '金额
Sht1.Activate
End If
Next kNum
Next jNum
End Sub
因为刚学vba很多不懂,不会在不同的工作表遍历行,读取有用信息复制到入库单,而且要考虑此公司一张单据不够打印,多余行要打印第二张 入库单,从头开始。明细表的详细数据有七百多行,请大神帮忙制作学习,谢谢!!!
|
|