SOLVED

How do you create table that automatically add or delete rows?

%3CLINGO-SUB%20id%3D%22lingo-sub-2649039%22%20slang%3D%22en-US%22%3EHow%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2649039%22%20slang%3D%22en-US%22%3E%3CP%3ESuppose%20I%20have%20the%20tools%20list%20and%20its%20changes%20tabulated%20below%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-08-14%20210122.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303300iB8C9AB8BC3928608%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-08-14%20210122.png%22%20alt%3D%22Screenshot%202021-08-14%20210122.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThen%20in%20the%20bottom%20table%20I%20recorded%20a%20change%20of%20adding%202%20bolts.%20How%20do%20you%20make%20the%20tool%20table%20automatically%20add%20a%20row%20in%20the%20top%20table%20and%20appear%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-08-14%20210004.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303299i4E1CA8AA68F00E8E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-08-14%20210004.png%22%20alt%3D%22Screenshot%202021-08-14%20210004.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIn%20reverse%2C%20if%20I%20used%20up%205%20nails%2C%20how%20do%20you%20make%20the%20tool%20table%20automatically%20delete%20a%20row%20in%20the%20top%20table%20and%20appear%20like%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-08-14%20210406.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303302iAD272DA9DA970993%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-08-14%20210406.png%22%20alt%3D%22Screenshot%202021-08-14%20210406.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20table%20that%20record%20changes%20should%20be%20the%20one%20that%20increases%20forever%2C%20while%20the%20top%20table%20will%20expand%20or%20contract%20depending%20on%20the%20availability%20of%20tools.%E2%80%83%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2649039%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2649183%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2649183%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1128622%22%20target%3D%22_blank%22%3E%40Mailutoronto%3C%2FA%3E%26nbsp%3BWhy%20not%20build%20one%20table%20with%20beginning%20quantities%20and%20all%20subsequent%20changes%20and%20then%20summarize%20that%20one%20with%20a%20pivot%20table%3F%20Example%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2649245%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2649245%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1128622%22%20target%3D%22_blank%22%3E%40Mailutoronto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20way%20is%20to%20use%20VBA%20in%20order%20to%20achieve%20this%20functionality.%3C%2FP%3E%3CP%3EIn%20the%20attached%2C%20you%20will%20find%20two%20tables%20named%20%22Main%22%20and%20%22Change%22%20where%20table%20%22Main'%20contains%20some%20records.%20And%20once%20you%20start%20adding%20records%20in%20the%20Change%20Table%2C%20the%20Main%20Table%20will%20update%20accordingly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Sheet1%20Module%20Contains%20the%20following%20Change_Event%20Code%20in%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0AIf%20Target.CountLarge%20%26gt%3B%201%20Then%20Exit%20Sub%0A%0ADim%20tblMain%20%20%20%20%20As%20ListObject%0ADim%20tblChange%20%20%20As%20ListObject%0ADim%20n%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20r%20%20%20%20%20%20%20%20%20%20%20As%20ListRow%0ASet%20tblMain%20%3D%20ActiveSheet.ListObjects(%22Main%22)%0ASet%20tblChange%20%3D%20ActiveSheet.ListObjects(%22Change%22)%0AOn%20Error%20GoTo%20Skip%0A%0AIf%20Not%20Intersect(Target%2C%20tblChange.DataBodyRange.Cells)%20Is%20Nothing%20Then%0A%20%20%20%20Application.EnableEvents%20%3D%20False%0A%20%20%20%20If%20Target.Column%20%3D%20tblChange.DataBodyRange.Columns(1).Column%20Then%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20n%20%3D%20Application.Match(Target.Value%2C%20tblMain.DataBodyRange.Columns(1)%2C%200)%0A%20%20%20%20%20%20%20%20If%20IsError(n)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20tblMain.DataBodyRange.Cells(1)%20%3D%20%22%22%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Set%20r%20%3D%20tblMain.ListRows.Add(1)%0A%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Set%20r%20%3D%20tblMain.ListRows.Add%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20r.Range(1%2C%201).Value%20%3D%20Target%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Target.Offset(0%2C%202).Value%20%3D%20Date%0A%20%20%20%20%20%20%20%20Target.Offset(0%2C%202).NumberFormat%20%3D%20%22dd-mmm-yyyy%22%0A%20%20%20%20ElseIf%20Target.Column%20%3D%20tblChange.DataBodyRange.Columns(2).Column%20Then%0A%20%20%20%20%20%20%20%20n%20%3D%20Application.Match(Target.Offset(0%2C%20-1).Value%2C%20tblMain.DataBodyRange.Columns(1)%2C%200)%0A%20%20%20%20%20%20%20%20If%20Not%20IsError(n)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20Set%20r%20%3D%20tblMain.ListRows(n)%0A%20%20%20%20%20%20%20%20%20%20%20%20r.Range(1%2C%202).Value%20%3D%20r.Range(1%2C%202).Value%20%2B%20Target.Value%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20r.Range(1%2C%202).Value%20%3D%200%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tblMain.ListRows(n).Delete%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Target.Offset(0%2C%201).Value%20%3D%20Date%0A%20%20%20%20%20%20%20%20Target.Offset(0%2C%201).NumberFormat%20%3D%20%22dd-mmm-yyyy%22%0A%20%20%20%20End%20If%0AEnd%20If%0ASkip%3A%0AApplication.EnableEvents%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2649472%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2649472%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1128622%22%20target%3D%22_blank%22%3E%40Mailutoronto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExcel%20365%20can%20achieve%20similar%20goals%20with%20worksheet%20formulas.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20366px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F303316i20BABC74CCAD8597%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%20LET(%0A%20%20tool%2C%20%20%20%20%20UNIQUE(Change%5BTools%5D)%2C%0A%20%20stock%2C%20%20%20%20SUMIFS(Change%5BQty%5D%2C%20Change%5BTools%5D%2C%20tool)%2C%0A%20%20stockQty%2C%20CHOOSE(%7B1%2C2%7D%2C%20tool%2C%20stock)%2C%0A%20%20FILTER(stockQty%2C%20stock%26gt%3B0))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2650023%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2650023%22%20slang%3D%22en-US%22%3EPivot%20table%20does%20help%20with%20customizing%20a%20summary%20of%20the%20data.%20However%2C%20the%20reason%20I%20specifically%20wanted%20to%20achieve%20this%20the%20way%20I%20wanted%20is%20because%20its%20a%20small%20component%20of%20a%20much%20larger%20project%20that%20I%20actually%20want%20to%20do%3A%20stock%20portfolio.%3CBR%20%2F%3EThe%20entries%20will%20be%20numerals%20but%20less%20detailed%2C%20while%20the%20summary%20will%20be%20really%20detailed%20but%20few%20and%20change%20according%20to%20the%20entries.%20The%20pivot%20table%2C%20as%20far%20as%20I%20know%2C%20won't%20be%20as%20useful.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2658183%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2658183%22%20slang%3D%22en-US%22%3EThis%20includes%20the%20function%20that%20I%20imagined.%20However%2C%20it%20does%20include%20flows.%20No%20need%20to%20fix%20because%20I%20think%20I'll%20have%20to%20learn%20VBA%20now%20and%20I%20wasn't%20exactly%20expecting%20this%20since%20almost%20all%20of%20my%20previous%20sheets%20were%20well%20handled%20by%20Excel%20without%20VBA%2FMacros.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20rows%20auto%20add%20and%20auto%20deleted%20based%20on%20variables%20that%20is%20quite%20narrow%20and%20leads%20to%20some%20malfunctions.%20I'll%20have%20to%20include%20more%20rules%20myself.%3CBR%20%2F%3E%3CBR%20%2F%3ECan%20you%20point%20me%20to%20certain%20topics%20in%20VBA%20to%20learn%20what%20you%20did%3F%20or%20do%20I%20have%20to%20learn%20everything%20from%20scratch%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2658187%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2658187%22%20slang%3D%22en-US%22%3Ethanks%20for%20your%20response.%20I%20don't%20know%20what%20it%20is%20you%20did%20here.%20Are%20the%20codes%20in%20VBA%2FMacro%3F%20If%20so%2C%20I%20think%20I%22ll%20have%20to%20learn%20it%20myself%20since%20I%20never%20used%20it%20in%20Excel%20before.%3CBR%20%2F%3E%3CBR%20%2F%3EAre%20you%20able%20to%20point%20me%20to%20some%20sources%20for%20learning%20what%20it%20is%20you%20did%20and%20maybe%20the%20topics%20that%20can%20quickly%20guide%20me.%20Or%20should%20I%20learn%20whatever%20it%20is%20from%20scratch%3F%20Thank%20you%2C%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2658197%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2658197%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1128622%22%20target%3D%22_blank%22%3E%40Mailutoronto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20just%20a%20regular%20Excel%20formula.%26nbsp%3B%20OK%2C%20not%20so%20regular%20since%20most%20users%20will%20not%20recognise%20the%20formula%20as%20Excel!%26nbsp%3B%20The%20following%20announces%20that%20LET%20is%20now%20generally%20available%20on%20Excel%20365.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel-blog%2Flet-names-in-formulas-generally-available%2Fba-p%2F1878903%22%20target%3D%22_blank%22%3ELET%20Generally%20Available%20(microsoft.com)%3C%2FA%3E%3C%2FP%3E%3CP%3ESearches%20of%20the%20Microsoft%20site%20should%20give%20links%20to%20the%20introduction%20of%20Dynamic%20Arrays%20(2018)%2C%20the%20Announcement%20of%20LET%20and%2C%20still%20on%20insider%20beta%20channels%20the%20announcement%20of%20Lambda%20functions%20and%20Lambda%20helper%20functions%20that%20feed%20array%20parameters%20into%20Lambda%20functions%20and%20collect%20the%20results%20to%20form%20an%20array%20of%20results.%3C%2FP%3E%3CP%3EIt%20all%20represents%20the%20most%20dramatic%20change%20imaginable.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2658292%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20you%20create%20table%20that%20automatically%20add%20or%20delete%20rows%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2658292%22%20slang%3D%22en-US%22%3EI%20have%20gathered%20some%20answers%20to%20my%20question%20above%2C%20but%20was%20your%20Tools%20table%20adding%20rows%20and%20deleting%20rows%20depending%20on%20the%20changes%20in%20the%20tools%3F%3C%2FLINGO-BODY%3E
Occasional Contributor

Suppose I have the tools list and its changes tabulated below:

Screenshot 2021-08-14 210122.png

Then in the bottom table I recorded a change of adding 2 bolts. How do you make the tool table automatically add a row in the top table and appear like this:

 

Screenshot 2021-08-14 210004.png

In reverse, if I used up 5 nails, how do you make the tool table automatically delete a row in the top table and appear like this:

Screenshot 2021-08-14 210406.png

The table that record changes should be the one that increases forever, while the top table will expand or contract depending on the availability of tools. 

 

 

12 Replies

@Mailutoronto Why not build one table with beginning quantities and all subsequent changes and then summarize that one with a pivot table? Example attached.

best response confirmed by Mailutoronto (Occasional Contributor)
Solution

@Mailutoronto 

One way is to use VBA in order to achieve this functionality.

In the attached, you will find two tables named "Main" and "Change" where table "Main' contains some records. And once you start adding records in the Change Table, the Main Table will update accordingly.

 

The Sheet1 Module Contains the following Change_Event Code in it.

 

 

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub

Dim tblMain     As ListObject
Dim tblChange   As ListObject
Dim n           As Variant
Dim r           As ListRow
Set tblMain = ActiveSheet.ListObjects("Main")
Set tblChange = ActiveSheet.ListObjects("Change")
On Error GoTo Skip

If Not Intersect(Target, tblChange.DataBodyRange.Cells) Is Nothing Then
    Application.EnableEvents = False
    If Target.Column = tblChange.DataBodyRange.Columns(1).Column Then
    
        n = Application.Match(Target.Value, tblMain.DataBodyRange.Columns(1), 0)
        If IsError(n) Then
            If tblMain.DataBodyRange.Cells(1) = "" Then
                Set r = tblMain.ListRows.Add(1)
            Else
                Set r = tblMain.ListRows.Add
            End If
            r.Range(1, 1).Value = Target
        End If
        Target.Offset(0, 2).Value = Date
        Target.Offset(0, 2).NumberFormat = "dd-mmm-yyyy"
    ElseIf Target.Column = tblChange.DataBodyRange.Columns(2).Column Then
        n = Application.Match(Target.Offset(0, -1).Value, tblMain.DataBodyRange.Columns(1), 0)
        If Not IsError(n) Then
            Set r = tblMain.ListRows(n)
            r.Range(1, 2).Value = r.Range(1, 2).Value + Target.Value
            If r.Range(1, 2).Value = 0 Then
                tblMain.ListRows(n).Delete
            End If
        End If
        Target.Offset(0, 1).Value = Date
        Target.Offset(0, 1).NumberFormat = "dd-mmm-yyyy"
    End If
End If
Skip:
Application.EnableEvents = True
End Sub

 

 

 

@Mailutoronto 

Excel 365 can achieve similar goals with worksheet formulas.

image.png

= LET(
  tool,     UNIQUE(Change[Tools]),
  stock,    SUMIFS(Change[Qty], Change[Tools], tool),
  stockQty, CHOOSE({1,2}, tool, stock),
  FILTER(stockQty, stock>0))
Pivot table does help with customizing a summary of the data. However, the reason I specifically wanted to achieve this the way I wanted is because its a small component of a much larger project that I actually want to do: stock portfolio.
The entries will be numerals but less detailed, while the summary will be really detailed but few and change according to the entries. The pivot table, as far as I know, won't be as useful.
This includes the function that I imagined. However, it does include flows. No need to fix because I think I'll have to learn VBA now and I wasn't exactly expecting this since almost all of my previous sheets were well handled by Excel without VBA/Macros.

The rows auto add and auto deleted based on variables that is quite narrow and leads to some malfunctions. I'll have to include more rules myself.

Can you point me to certain topics in VBA to learn what you did? or do I have to learn everything from scratch?
thanks for your response. I don't know what it is you did here. Are the codes in VBA/Macro? If so, I think I"ll have to learn it myself since I never used it in Excel before.

Are you able to point me to some sources for learning what it is you did and maybe the topics that can quickly guide me. Or should I learn whatever it is from scratch? Thank you,

@Mailutoronto 

It is just a regular Excel formula.  OK, not so regular since most users will not recognise the formula as Excel!  The following announces that LET is now generally available on Excel 365.

LET Generally Available (microsoft.com)

Searches of the Microsoft site should give links to the introduction of Dynamic Arrays (2018), the Announcement of LET and, still on insider beta channels the announcement of Lambda functions and Lambda helper functions that feed array parameters into Lambda functions and collect the results to form an array of results.

It all represents the most dramatic change imaginable.

I have gathered some answers to my question above, but was your Tools table adding rows and deleting rows depending on the changes in the tools?

@Mailutoronto 

Sadly some of my naming was not helpful.  In the following

FILTER(stockQty, stock>0)

the first term was a two column array of tool name and its total quantity.  The second was the stock quantity.  What FILTER does is retain the rows that satisfy the condition

stock > 0

so giving a fully dynamic result that changes as the data is revised.  I used LET simply because that is the way I program Excel.  In this instance it would be pretty easy to do without by nesting the variable definitions within the final formula.

= FILTER(
    CHOOSE(
      {1,2}, 
      UNIQUE(Change[Tools]), 
      SUMIFS(Change[Qty], Change[Tools], tool)), 
    SUMIFS(Change[Qty], Change[Tools], tool)>0)
  )
Where are you entering these codes? They look very much like VBA (I'm in the middle of learning).
2nd, although I recognize those formula, but I have no idea how it is supposed to be implemented on the sheet.

I'm not that great with Excel so I can't comment on whether if this works the way I wanted it to. The commentor above, however, did achieve what I wanted it to do with bugs.

Still, thanks for looking into this. I'll have to revisit this sometime later. I'm still in the middle of learning VBA.
Without VBA you can use sequence and if with some logical cheat, see my post on aug 23 2021

@Mailutoronto 

You are not alone.  It happens frequently that the Excel 365 formulas I publish are not even recognised as spreadsheet formulas!  I have tidied up the naming a little to make the quantities a little clearer.

= LET(
  tool,     UNIQUE(Change[Tool]),
  stockQty, SUMIFS(Change[Qty], Change[Tool], tool),
  stockTbl, CHOOSE({1,2}, tool, stockQty),
  FILTER(stockTbl, stockQty>0))

The formula that generates the table is in cell F3.   A fairly normal trick for debugging a LET formula, is to return one of the local names at a time as the result of the calculation

= LET(
  tool,     UNIQUE(Change[Tool]),
  stockQty, SUMIFS(Change[Qty], Change[Tool], tool),
  stockTbl, CHOOSE({1,2}, tool, stockQty),
  result,   FILTER(stockTbl, stockQty>0),
  stockTbl)

By inspecting each name in turn, one is able to gain insight and debug the formula.  So far, this only applies to Excel 365, but it represents the most profound change to occur in spreadsheet technology since they were first introduced in the 1980s.

 

This may represent the emergent butterfly, but many will continue to admire and play only with the caterpillars!