|
代码
Sub 自动填写入库明细()
'定义物料编码、开始日期、截止日期变量’
Dim wlbm As String, ksrq As Date, jzrq As Date
wlbm = Worksheets("入库明细查询").Cells(2, 2)
ksrq = Worksheets("入库明细查询").Cells(3, 2)
jzrq = Worksheets("入库明细查询").Cells(3, 4)
'定义变量类型
Dim h As Integer, i As Integer, k As Integer
'从指定工作表最后一行往上最后一个非空单元格’
h = Worksheets("入库单").[a65536].End(xlUp).Row
'定义入库明细表记录数据的起始行
k = 6
'从入库单第二行开始扫描,并把符合条件的内容写入入库明细查询表’
For i = 2 To h
Dim wb1 As Worksheet
Set wb1 = Worksheets("入库单")
Dim rq As Date
rq = wb1.Cells(i, 1)
If rq >= ksrq And rq <= jzrq And wlbm = Worksheets("入库单").Cells(i, 6) Then
Dim v As Integer
For v = 1 To 13
wb1.Cells(i, v).Copy Worksheets("入库明细查询").Cells(k, v)
Next v
k = k + 1
End If
Next i
End Sub
|
|