Guest post by Justin Bray, CTP Studios Scripts. Prepared with AI assistance. The formulas were tested in the linked Google Sheet with synthetic inventory data. Want to write for Better Sheets too? Here's how guest posts work.
Two rows in a product upload can have the same SKU and disagree about how many units are on hand. In the sample below, a tote appears with a quantity of 12 on one row and 14 on another. Before either number reaches a shop import, Google Sheets can highlight both rows so you can check which value belongs in the file.
Follow along with the sample Google Sheet.
This check applies to a product catalog or inventory snapshot that expects one row per SKU. An order history can legitimately repeat a SKU every time someone buys that item. Confirm what one row represents in your import before treating repeated keys as a problem.
Start with five sample products
Create a blank tab. Put these headers and records in A1:C6, starting with sku in A1. Everything here is synthetic. Leave A5 empty so the sample includes a product with a missing SKU.
- Row 1: sku, product, quantity
- Row 2: SKU-0017, Canvas tote, 12
- Row 3: SKU-0042, Desk tray, 7
- Row 4: SKU-0017, Canvas tote, 14
- Row 5: (empty), USB cable, 3
- Row 6: SKU-0104, Cable ties, 5
If your real IDs can be all digits, select column A and set Format → Number → Plain text before entering or pasting them. The zeroes in 0017 may be part of the ID. If a previous import already turned 0017 into the number 17, changing the cell format later cannot recover the original ID. Re-enter it from the original source and check the exported CSV in a text editor. The prefix in the sample SKUs keeps the identifiers unambiguous while you learn the workflow. Google Sheets number formats
Highlight both rows with a repeated SKU
Select A2:C6, then open Format → Conditional formatting. In the sidebar, set Format cells if to Custom formula is and enter the formula below. Pick a light red fill and click Done. The formula uses the comma argument separator. If your spreadsheet uses a different locale, use the formula separators appropriate to that file. Google’s conditional formatting guide
=AND($A2<>"",COUNTIF($A$2:$A$6,$A2)>1)
Sheets evaluates the rule starting at row 2. The dollar sign in $A2 keeps the test pointed at column A as the format is applied across the row. The row number can still move. The fully anchored $A$2:$A$6 keeps every row looking at the same list of SKUs.
Rows 2 and 4 should both turn red. For each of those rows, COUNTIF finds two occurrences of SKU-0017. Row 5 stays uncolored because the first part of the formula excludes an empty SKU.
Add a second rule to the same range and give it an amber fill. This rule flags a record that has a product name and an empty SKU.
=AND($A2="",$B2<>"")
Row 5 should now turn amber. On a real catalog, extend the formatting range and the anchored count range together as you add rows. If you change one range and forget the other, new products can fall outside the duplicate count.
Add a status you can filter
Color helps you scan the sheet. A text status makes it easier to filter a longer list, and it stays readable without color. Put Import status in D1, enter this formula in D2, and fill it down through D6.
=IF(COUNTA($A2:$C2)=0,"",IF($A2="","Missing SKU",IF(COUNTIF($A$2:$A$6,$A2)>1,"Duplicate SKU","OK")))
The statuses, in order, should be Duplicate SKU, OK, Duplicate SKU, Missing SKU, and OK. If you add a filter to A1:D6, you can filter the status column to review just the records that need attention. The sample checks for empty SKU cells. Before using it on imported data, review any values made only of spaces and confirm with your source which spaces are meaningful.
For the two red rows, look up the current tote quantity in your inventory source and keep the record that reflects it. For the amber row, look up the cable’s actual SKU. If the source lacks an identifier, hold the row until you can confirm one. The status column identifies where to work. The source determines what the corrected record should say.
COUNTIF treats upper- and lowercase as equivalent and can interpret asterisks and question marks in text criteria as wildcards. The example uses a consistent uppercase SKU format with letters, digits, and a dash. If your importer treats case or wildcard characters as significant, adapt the comparison to that importer before applying this rule to production IDs. Google’s COUNTIF reference
Export the product columns
Once you’ve reconciled the flagged rows, copy the headers and confirmed values in columns A through C to a fresh export tab. Set its SKU column to Plain text first if you have numeric-looking IDs. Use Edit → Paste special → Values only so the export tab contains just the product data. With that tab open, choose File → Download → Comma-separated values (.csv). Open the downloaded file in a text editor and check the header and a few representative IDs against your sheet.
The extra tab gives you a clean place to inspect what the importer will receive. Keep the working tab for the next batch, with its colors, status formulas, and the record of what needed attention.
If you also want a second check on the downloaded file, CTP Studios Scripts publishes Check a CSV, a free tool that opens locally in desktop Chrome or Edge after you extract its ZIP. Open Open.html, choose the CSV and its sku column, and run the check. On the original synthetic rows, the duplicate would be reported on CSV line 4 with its first occurrence on line 2, and the missing ID on line 5. The report gives line numbers and issue types without including your cell values. Your importer can still have its own required fields or rules, so use its specifications for the final check.
About the author
Justin Bray
Justin runs CTP Studios Scripts, which makes spreadsheet and CSV tools for shop operators, including the free Check a CSV.
This is a guest post. Read about guest posts on Better Sheets.