use formula to pull cells with certain values to another work sheet

jwevans

New Member
Joined
Oct 12, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have an inventory spreadsheet that keeps a running total of inventory. I need to add a totals page that tracks sales, for re-order info. The Inventory worksheet shows sales as a negative number in column H. I would like to capture this number, only for part numbers that actually have sales for the day on another sheet that tracks the daily sales for a week.

INVENTORY MANAGEMENT
CodeDescriptionPurchQtyPurchCostAvCoSaleQtySaleValueProfitInventoryQtyInventoryValue
31P-735Heavy Duty
5​
5.00​
1.00​
-3​
-90.00​
-87.00​
2​
2.00​
315-735Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
31P-950Heavy Duty
2​
2.00​
1.00​
-1​
-12.00​
-11.00​
1​
1.00​
315-950Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
3EE-420Heavy Duty
2​
2.00​
1.00​
0​
0.00​
0.00​
2​
2.00​
3ET-525Heavy Duty
2​
2.00​
1.00​
0​
0.00​
0.00​
2​
2.00​
3EH-Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
8U1Heavy Duty
0​
0.00​
0.00​
0​
0.00​
0.00​
0​
0.00​
1-650Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
2-800Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
3-Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
4D-1000Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
4DL+-950Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
8D-1400Heavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
8D WATERFLL TERMINALHeavy Duty
1​
1.00​
1.00​
0​
0.00​
0.00​
1​
1.00​
0​
0.00​
0.00​
0​
0.00​
0.00​
0​
0.00​
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hello,

I tried to make something from what I understood from your post. If this does not work as wanted, please provide a more detailed description of what you need - best done through a copy of your workbook (de-sensitized if necessary).

Try this on a copy of your workbook:

VBA Code:
Private Sub jwevans_sub()
    Dim wb As Workbook
    Dim ws As Worksheet, nws As Worksheet
    Dim Lrow As Long
    Dim r1 As Range, r2 As Range, r3 As Range, mr As Range
    Dim sheetname As String
  
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Sheet1")        '<-----  Insert the sheetname of the sales data here "Sheetname"
  
    Application.ScreenUpdating = False
  
    sheetname = "Sales summary Week " & WorksheetFunction.WeekNum(Now, vbMonday) - 1
  
    Sheets.Add.Name = sheetname
  
    Set nws = wb.Worksheets(sheetname)
    With nws
       .Range("A1") = "Code"
       .Range("B1") = "SaleQty"
       .Range("C1") = "InventoryQty"
       .Range("D1") = "InventoryValue"
    End With
  
    ws.Range("H2").AutoFilter Field:=6, Criteria1:="-*"
  
    Lrow = ws.Cells(Rows.Count, 8).End(xlUp).Row
  
    Set r1 = ws.Range("C3:C" & Lrow)
    Set r2 = ws.Range("H3:H" & Lrow)
    Set r3 = ws.Range("K3:L" & Lrow)
    Set mr = Union(r1, r2, r3)
  
    mr.SpecialCells(xlCellTypeVisible).Copy
    nws.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValuesAndNumberFormats)
    nws.Columns.AutoFit
  
    ws.ShowAllData
  
    nws.Activate
    Application.ScreenUpdating = True
  
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,483
Messages
6,125,063
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top