How to Assign Unique SKUs to Repeated Style IDs in Excel
Question details
The user needs to match sales rows to stock rows based on Style IDs and assign a unique SKU to each repeated style without duplicating SKUs.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing inventory and sales records where multiple sales items share the same Style ID but require distinct, unique SKUs for tracking.
- Observed behavior
- The user wants to sequentially assign unique SKUs from a stock table to corresponding sales rows based on the occurrence count of each Style ID.
Ensure that your Stock table contains enough unique SKUs for every occurrence of a Style ID in your Sales table to avoid lookup errors.
Use COUNTIF and INDEX/MATCH to Assign Unique SKUs
Count the occurrences of each Style ID to create a unique identifier, then use that to retrieve the corresponding unique SKU from the stock table.
This method uses the COUNTIF function with an expanding range to determine which occurrence of a Style ID you are currently processing in the Sales table. It then matches this occurrence number against the Stock table to fetch the exact row and ensure no SKUs are duplicated.
In your Stock table, insert a new column next to your Style IDs. Use a COUNTIF formula like =COUNTIF($A$2:A2, A2) and drag it down. This numbers each repeated Style ID sequentially (1, 2, 3, etc.).
In your Sales table, insert a similar helper column. Apply the same expanding COUNTIF formula =COUNTIF($A$2:A2, A2) to count the occurrence of each Style ID being sold.
To make matching easier, you can concatenate the Style ID and the helper number in a new column in both tables using a formula like =A2&"-"&B2.
In your Sales table's SKU column, use an INDEX and MATCH formula to pull the SKU. For example: =INDEX(Stock_SKU_Range, MATCH(Sales_Combined_ID, Stock_Combined_ID_Range, 0)). This ensures the exact, unused SKU is matched to the correct sale.

Manage Inventory and SKUs Easily with WPS Spreadsheet
WPS Spreadsheet provides powerful functions like XLOOKUP, COUNTIF, and FILTER to help you manage complex inventory tracking, assign unique SKUs, and handle repeated Style IDs with ease.
- 1. Open your data: Launch WPS Spreadsheet and open your inventory and sales workbook.
- 2. Apply COUNTIF: Use the COUNTIF function in a new column to track the occurrence of each Style ID.
- 3. Retrieve SKUs: Use the XLOOKUP or INDEX/MATCH function to pull the corresponding unique SKU based on the Style ID and occurrence number.
- 4. Save and Export: Save your updated workbook in .xlsx format for full compatibility with other spreadsheet software.

Frequently Asked Questions
What happens if there are not enough SKUs in the stock table?
If your sales occurrences exceed the available unique SKUs in the stock table, lookup formulas will return an #N/A or #REF! error. You must ensure your stock table is fully populated to cover every sale.
Can I use XLOOKUP to assign unique SKUs?
Yes. XLOOKUP is highly efficient for matching multiple criteria. You can concatenate the Style ID and occurrence number in both tables directly within the formula array and use XLOOKUP to find the exact match.
How do I prevent duplicate SKUs from being assigned?
By using the expanding range in your COUNTIF formula (e.g., $A$2:A2), you assign a unique sequential number to each repeated Style ID. Matching this specific number, rather than just the Style ID, prevents the formula from grabbing the first SKU multiple times.
Does WPS Office support these advanced lookup functions?
Absolutely. WPS Spreadsheet fully supports standard functions like COUNTIF, INDEX, MATCH, and modern arrays like XLOOKUP, ensuring your inventory formulas work seamlessly without compatibility issues.




