本帖最后由 龙送农68 于 2023-9-23 16:02 编辑
vba排序和i列非0信息调用
用vba: 1、将“库存汇总”表按结存数量i列进行排序; 2、先将“库存汇总”表的食品名称为"大米"和"菜仔油"信息调到出库单,然后按结存数量不为0的信息调用再调到出库单(出库单表的b至d 列等于库存汇总表的b至d 列,出库单的e至f列等于库存汇总表的i至j 列).
- Sub 林demo2()
- '到出库单
- Dim h As Integer, arr, i As Integer, K As Integer
- With Sheet1
- h = .Range("b65535").End(xlUp).Row
- arr = .Range("b6:j" & h)
- For i = 1 To UBound(arr)
- If arr(i, 1) = "大米" Or arr(i, 1) = "菜籽油" Then
- If arr(i, 8) > 0 Then
- K = K + 1
- Sheet2.Range("B" & K + 6).Resize(1, 3) = .Range("B" & i + 5).Resize(1, 3).Value
- Sheet2.Range("E" & K + 6).Resize(1, 2) = .Range("I" & i + 5).Resize(1, 2).Value
- End If
- End If
- Next i
- End With
- End Sub
复制代码
|