if you're not already familiar with them, you might find it useful to read up on pivot tables and data aggregation functions like DSUM. there are plenty of how-to guides out there on these 2 concepts that can probably explain them way better than i could.
i find them both very useful for trading spreadsheets, i use them liberally in my own Excel workbook. they're particularly useful for letting you maintain a trade by trade worksheet where you can see every individual parcel, and summary sheets to give you an overall picture of your portfolio that nicely auto-update every time you make an entry in the trade by trade worksheet.
if i have multiple parcels of the same stock that turns into multiple lines on the trade by trade worksheet, but it all aggregates into a single line per stock on the summary sheet as pivot tables let you do a group by on a specific field (ie. the stock ticker). if i partially sell a parcel i split that parcel into 2 rows on the trade by trade sheet so one row is completely closed out and the other holds the remaining units of that parcel. the pivot tables make sure the summary worksheet automatically gets the latest numbers whenever i update the trade by trade worksheet.