Function Problems

Build a Barcode String from Code, Date, Weight, and Carton Number in Excel

Jason MillerJason Miller Nov 18, 2026 869 views

Question details

Create a barcode value by combining a code, weight, formatted date, and carton number in a spreadsheet.

Build a Barcode String from Code, Date, Weight, and Carton Number in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains barcode components in separate cells, and the user wants to assemble them in a specified order.
Observed behavior
The desired result is a single string containing the code, weight without a decimal point, date in YYMMDD format, a fixed 00, and a four-digit carton number.
Before you start

Check that the date is a valid spreadsheet date and confirm the required field order and lengths with your barcode specification. Store codes with leading zeros as text, and verify how many digits the weight must contain.

Solution 1Recommended

Combine the barcode components with an Excel formula

Use this formula when the code is in A2, date in C2, carton number in D2, and weight in E2.

The formula joins the fields in the order code, weight, date, fixed 00, and carton number. TEXT formats the date as YYMMDD and pads carton numbers shorter than four digits with leading zeros.

SUBSTITUTE removes a period from the weight; it does not enforce a fixed weight length. Adjust the weight formatting or decimal separator to match your data and barcode specification.

1
Check the source cells

In your worksheet, confirm that A2 contains the code, C2 the date, D2 the carton number, and E2 the weight. Change the references in the formula if your columns differ.

2
Enter the formula

Select an empty cell, enter =A2&SUBSTITUTE(E2&"",".","")&TEXT(C2,"yymmdd")&"00"&TEXT(D2,"0000"), and press Enter.

3
Check and fill the results

Compare the result with your required barcode layout, then drag the cell's fill handle down to apply the formula to other rows.

Combine the barcode components with an Excel formula
A string is not a barcode image: The formula creates the data string only. To produce a scannable barcode, use a barcode generator or font that supports your required symbology and any required check digit.
Build barcode strings in WPS Spreadsheet

Combine barcode fields in WPS Spreadsheet

Use WPS Spreadsheet to join the code, weight, date, and carton number with the same TEXT and SUBSTITUTE formula, then fill it down for other rows.

  1. 1. Open the worksheet: Open WPS Spreadsheet and use Open to select your workbook.
  2. 2. Check the fields: Confirm that A2 contains the code, C2 the date, D2 the carton number, and E2 the weight, or adjust the formula references to match your sheet.
  3. 3. Enter the formula: Select an empty cell and enter =A2&SUBSTITUTE(E2&"",".","")&TEXT(C2,"yymmdd")&"00"&TEXT(D2,"0000"), then press Enter.
  4. 4. Verify and fill down: Check the resulting string against your barcode specification, then drag the fill handle down to calculate the remaining rows.
Build barcode data strings from separate worksheet fieldsFormat dates and pad carton numbers with leading zerosOpen and save Microsoft Excel XLSX filesUse familiar spreadsheet formulas and controls
microsoft office alternative - wps office

Frequently Asked Questions

How do I keep leading zeros in the code?

Format the code column as Text before entering the codes. If a numeric code has already lost its leading zeros, restore them using the required code length or re-enter the code as text.

What date order does the formula use?

TEXT(C2,"yymmdd") returns a six-digit year-month-day value. Change the format in TEXT if your barcode specification requires a different date order.

Does the formula make the weight a fixed length?

No. SUBSTITUTE(E2&"",".","") removes a period but does not pad the weight or guarantee a fixed number of digits. Adjust the weight formatting to match the required precision and field length.

Can I scan the result as a barcode?

Not by itself. The result is a text string; use a compatible barcode generator or font and follow your symbology's rules, including any required check digit.