If I understood you correctly, try placing this together in your Worksheet_Change event codes, right at the top.
The cell the code is reading is BB2. You have to unprotect your sheet and unlock this cell first, since it's locked and protect in your file. You can edit it to be another cell you like.
The idea is to have this as the "input textbox", so have this cell selected, then scan your codes. It will be searched for a match, and sees the number of pallets below it, adds 1 OR find another match or for a next empty cell if it's already 15. I've added explanatory comments to help you understand the codes.
Bookmarks