A storage import shows 0042 in two rows. One row contains a text identifier with its leading zeros. The other contains the number 42 displayed with four digits. Check the underlying type before matching either row to the registry.

Build a strict text helper

In an Excel test sheet, enter 0042 as text in A2 and 42 as a number in A3. In B2, enter =VALUETOTEXT(A2,1) and fill down. The second argument selects strict representation. The text row should include quotation marks around the identifier.

Example cells show 0042 entered as text and 42 entered as a number, with different strict VALUETOTEXT results.

Example source values. Quotes in the helper indicate the text representation.

Confirm the type directly

Format A3 with the custom number format 0000 so both source cells appear to show 0042. Then enter =ISTEXT(A2) in C2 and fill down. Expect TRUE for A2 and FALSE for A3. This check asks about the source cell rather than relying on its visible format.

The two cells display 0042 after number formatting, but ISTEXT reports TRUE for the first and FALSE for the second.

Example type check. Test the original cell rather than reading its visible formatting.

Keep the import intact until you know whether leading zeros are part of the registry key. A conversion that makes the two rows look the same can also merge records you need to keep distinct.

Microsoft’s VALUETOTEXT reference.