Home > database >  List items with quantity above greater or equal to 1
List items with quantity above greater or equal to 1

Time:06-09

I have to do this excel sheet at work and I'm kindof stuck at this problem. I need to create a list in sheet 3 with the items that have been selected in sheet 2 (valid selection is when Quantity is equal or greater then 1).

So that in the cells in sheet 3 only the items requested appear and the quantity desired. I was going to try and use a filter function but I cannot use that because I must use Excel 2016 which does not have it.

I have attached 2 screenshots to better illustrate my problem. Thanks in advance. (Image 1) (Image 2)

CodePudding user response:

It is easier to create a macro. ALT F11 and copy and paste the text below in a module. You can modify the rng and other variables if you want.

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
  • Related