列出数量大于等于1的项目

  • 本文关键字:项目 大于 excel list filter
  • 更新时间 :
  • 英文 :


我必须在工作中做这个excel表格,我有点卡在这个问题上。我需要在表3中创建一个列表,其中包含在表2中已选择的项目(当Quantity等于或大于1时,有效选择)。

以便在表格3中的单元格中只显示请求的项目和所需的数量。我打算尝试使用过滤器函数,但我不能使用它,因为我必须使用Excel 2016,它没有。

我附上了2个截图,以更好地说明我的问题。提前感谢。(图1)(图2)

创建宏更容易。ALT + F11,复制并粘贴下面的文本到一个模块中。如果需要,可以修改rng和其他变量。

Public Sub copy_quantity()
Dim ws As Worksheet
Dim ws_copy As Worksheet
Dim rng As Range
Dim lr As Long
Set ws = ThisWorkbook.Sheets("Dati Richiesti") 'The source worksheet
Set ws_copy = ThisWorkbook.Sheets("Ripilogo Richiesti") 'destination worksheet
Set rng = ws.Range("C6:C600") 'The range to check quantity
'Now loop through all quantities
For Each cell In rng
If cell > 0 Then
lr = ws_copy.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row 'Determine where to paste on the first empty row
ws.Range(cell.Offset(0, -1), cell.Offset(0, 1)).Copy Destination:=ws_copy.Range("a" & lr) ' copy paste from one sheet to the other
End If
Next ' check the following cell for the quantity
End Sub

最新更新