excel vba 代码 解读下
- 提问者网友:贪了杯
- 2021-03-11 10:56
If Sheets("出库明细").AutoFilterMode = True Then Sheets("出库明细").AutoFilterMode = False
If Sheets("订单明细").AutoFilterMode = True Then Sheets("订单明细").AutoFilterMode = False
If Sheets("物料信息").AutoFilterMode = True Then Sheets("物料信息").AutoFilterMode = False
arr = Sheets("入库明细").Range("A3:H" & Sheets("入库明细").[G65536].End(xlUp).Row)
drr = Sheets("出库明细").Range("A3:H" & Sheets("出库明细").[G65536].End(xlUp).Row)
err = Sheets("订单明细").Range("A3:H" & Sheets("订单明细").[G65536].End(xlUp).Row)
crr = Sheets("物料信息").Range("A2:G" & Sheets("物料信息").[B65536].End(xlUp).Row)
ReDim brr(1 To UBound(crr), 1 To 7)
For j = 1 To UBound(crr) '把所有货品列出来
If Not d2.exists(crr(j, 1)) Then
m = m + 1
d2(crr(j, 1)) = m
brr(m, 1) = crr(j, 1): brr(m, 2) = crr(j, 2): brr(m, 3) = crr(j, 3): brr(m, 4) = crr(j, 4): brr(m, 7) = crr(j, 4)
End If
Next
For i = 1 To UBound(arr)
If d2.exists(arr(i, 4)) Then
brr(d2(arr(i, 4)), 5) = brr(d2(arr(i, 4)), 5) + arr(i, 7)
brr(d2(arr(i, 4)), 7) = brr(d2(arr(i, 4)), 7) + arr(i, 7)
End If
Next
For k = 1 To UBound(drr)
If d2.exists(drr(k, 4)) Then
brr(d2(drr(k, 4)), 6) = brr(d2(drr(k, 4)), 6) + drr(k, 7)
brr(d2(drr(k, 4)), 7) = brr(d2(drr(k, 4)), 7) - drr(k, 7)
End If
Next
- 五星知识达人网友:鸠书
- 2021-03-11 11:03
楼主结合附件了解下,代码要解决什么问题
然后才能进一步解释代码的意思
不过一般解读别人的代码,不如自己编写来的快
- 1楼网友:woshuo
- 2021-03-11 12:02
右键单击工作表标签,选择查看代码,输入如下代码:
sub 保存历史数据() dim irow as integer dim i as integer dim ibook as workbook dim isht as worksheet on error resume next set ibook = getobject("f:\历史数据.xls") '假设保存到历史数据sheet1工作表中,若不是修改下句代码中的sheet1为对应工作表名称。 set isht = ibook.sheets("sheet1") with isht i = .range("a65536").end(xlup).row + 1 .range("a" & i) = "'" & worksheetfunction.text(i - 1, "00000") .range("b" & i) = "'" & worksheetfunction.text(date, "yyy-mm-dd") .range("c" & i) = worksheetfunction.text(time, "hh:mm:ss") .range("d" & i) = range("k3") .range("e" & i) = range("k4") .range("f" & i) = range("n4") .range("g" & i) = range("n4") .range("h" & i) = range("k5") .range("i" & i) = range("k6") end with ibook.windows(1).viluosible = true ibook.save ibook.close end sub
插入窗体控件按钮,更改显示名字为“保存”,指定宏“保存历史数据”。需要时,单击“保存”按钮即可。