Formula or Macro Highlight/Look Up SKUS that are Out of Stock from all Inventory Warehouse Locations

abarratt

New Member
Joined
May 3, 2016
Messages
2
I have a spreadsheet that has SKUs listed in first column and then the warehouse location and then a column for inventory (qty on hand, qty allocated, qty on order, qty backordered, qty future, qty available). Some skus are spread out among multiple warehouse locations so those SKUs are repeated. I need a formula or macros that will find and return all skus that out of stock in all columns and in all locations. Is there a way to do that? There are about 15,000+ Skus.
SKUWarehousePrefixQty On HandQty AllocatedQty BOQty OOQty FutureQty Available
1015-0021-TWEast Coast 3PL3PE00010600
1015-0021-TWLakawana1LK1000000
1015-0021-TW3 PLUS LOGISTICS3PL000000

<tbody>
</tbody>
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I have a spreadsheet that has SKUs listed in first column and then the warehouse location and then a column for inventory (qty on hand, qty allocated, qty on order, qty backordered, qty future, qty available). Some skus are spread out among multiple warehouse locations so those SKUs are repeated. I need a formula or macros that will find and return all skus that out of stock in all columns and in all locations. Is there a way to do that? There are about 15,000+ Skus.
SKUWarehousePrefixQty On HandQty AllocatedQty BOQty OOQty FutureQty Available
1015-0021-TWEast Coast 3PL3PE00010600
1015-0021-TWLakawana1LK1000000
1015-0021-TW3 PLUS LOGISTICS3PL000000

<tbody>
</tbody>

abarratt,
Welcome to the Forum.
This code will make a list on Sheet2 of all SKUs that have '0' or "" (blank) on Sheet1 column D for every warehouse that has that SKU.
Each SKU will only be listed once. It assumes your data is on Sheet1 with the SKU in column A, and the 'Qty On Hand' in column D, and the headers are in row 1.
You should try this on a copy of your workbook to avoid losing any data. It should be copied into a standard code module using 'Alt +F11' to access the VB Editor. After closing the Editor you should save the workbook as a 'macro-enabled' file. To run the macro press 'Alt+F8', then select 'ListOutOf Stock', then 'Run'. When it finishes, the macro posts a message box telling you it has finished. You will be looking at the new list on Sheet2.
Perpa
Code:
Sub ListOutOfStock()
Dim LastRow, LastRow2 As Long
Dim rw, n As Long
Dim cnt, cnt1 As Integer
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    For rw = 2 To LastRow
cnt = 0
cnt1 = 0
    For n = rw To LastRow
If n = rw Then GoTo SkipThisRow    'Don't count this row
If Cells(n, 1) = Cells(rw, 1) Then
     cnt1 = cnt1 + 1      'cnt1 keeps total of same sku found
        If Cells(rw, 4) = "" Or Cells(rw, 4) = 0 And Cells(n, 4) = "" Or Cells(n, 4) = 0 Then
               cnt = cnt + 1    'Keeps total of each sku with zero stock
        End If
End If
SkipThisRow:
    Next n
   LastRow2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1
   If cnt = cnt1 And cnt <> 0 Then Sheets("Sheet2").Cells(LastRow2, 1) = Sheets("Sheet1").Cells(rw, "A")
    Next rw
    
Sheets("Sheet2").Activate
'The  macro called below will eliminate any duplicate skus on Sheet2
Call OnlyOneSKU

Application.ScreenUpdating = True
MsgBox "Out of Stock Listing is Complete"
End Sub


Sub OnlyOneSKU()

    Dim Rng As Range
    Dim LastRow As Long
    Dim i As Long
    Dim sDupColumn As String

    sDupColumn = "A"
 
    Application.ScreenUpdating = False
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Set Rng = Range("A1:A" & LastRow)

'The following 'With' statement will sort the SKUs - I commented it out, but it can be used by removing the single quotes - Try running the rest of the code first with it commented out.
    'With Rng
       '.Sort key1:=Range(sDupColumn & 1), order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
            'Orientation:=xlTopToBottom
    'End With

    For i = LastRow To 2 Step -1
        If WorksheetFunction.CountIf(Range(Cells(2, sDupColumn), Cells(i, sDupColumn)), Cells(i, sDupColumn)) > 1 Then
            Rows(i).Delete
        End If
    Next i
    Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,081
Messages
6,128,695
Members
449,464
Latest member
againofsoul

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