Use this query-pivot-countifs pattern to get a list of dates in column B and the shots in column A associated with each date:
countifs(B1:B, B1:B, row(B1:B), "<=" & row(B1:B))
"select Col2, max(Col1)
where Col2 is ...
Your code appears to run on an installable on edit trigger. When you click a checkbox to run the code, the active sheet will be the one where you click, i.e., Outbound Parts.
You are saying that you want the code to use data from another sheet, i.e., Master. One way to do that would be to use Spreadsheet.getSheetByName() to get the Master sheet, and find ...