|
楼主 |
发表于 2018-7-9 16:42
|
显示全部楼层
Sub 导入进销存数据()
Dim m%, n%, o%, p%, a$, b$, rng1 As Range, rng2 As Range, c%
m = 8
c = ThisWorkbook.Worksheets(1).UsedRange.Columns.Count - 2
Do While ThisWorkbook.Worksheets(1).Cells(m, 2) <> ""
On Error Resume Next
a = Cells(m, 2).Value '将校验表里的经销商名称赋值给a
Set rng1 = Workbooks(2).Worksheets(1).Columns(3).Find(a, , , , , xlNext) '从进销存中查找a
n = rng1.Row '将进销存中查找到的a的行号赋值给n
Do
b = Workbooks(2).Worksheets(1).Cells(n, 5).Value '将品种名称赋值给b
Set rng2 = ThisWorkbook.Worksheets(1).Rows(6).Find(b, , , , , xlNext) '在校验表根据品种名称查找单元格
If Not rng2 Is Nothing Then
p = rng2.Column '将查找到的单元格的列号赋值给p
Workbooks(1).Worksheets(1).Cells(m, p + 1) = Workbooks(1).Worksheets(1).Cells(m, p + 1) + Workbooks(2).Worksheets(1).Cells(n, 6)
Workbooks(1).Worksheets(1).Cells(m, p + c / 3 + 1) = Workbooks(1).Worksheets(1).Cells(m, p + c / 3 + 1) + Workbooks(2).Worksheets(1).Cells(n, 8).Value + Workbooks(2).Worksheets(1).Cells(n, 9).Value
Workbooks(1).Worksheets(1).Cells(m, p + c / 3 * 2 + 1) = Workbooks(1).Worksheets(1).Cells(m, p + c / 3 * 2 + 1) + Workbooks(2).Worksheets(1).Cells(n, 16).Value
End If
n = n + 1
Loop While Workbooks(2).Worksheets(1).Cells(n, 3) = Workbooks(2).Worksheets(1).Cells(n - 1, 3)
m = m + 1
Loop
End Sub
您能帮忙看一下这个怎么修改么? |
|