Function Problems

Change the First Digit of Six-Digit Numbers in Excel

Camila MilosovichCamila Milosovich Dec 2, 2026 869 views

Question details

Change the leading digit from 1 to 2 only in six-digit values, preserving the other five digits.

Change the First Digit of Six-Digit Numbers in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains values such as 122811 that need to be changed to 222811 without altering other digits or nonmatching values.
Observed behavior
Only six-digit values beginning with 1 should receive a new first digit; other populated values should remain unchanged.
Before you start

Identify the column containing the values and choose an empty adjacent column for the formula. Check that the values are stored as six digits, rather than merely displayed with six digits by number formatting.

Solution 1Recommended

Use a Formula to Replace the Leading Digit

Use this method to change only six-digit values that begin with 1 and leave other populated values unchanged.

1
Enter the formula

If the first value is in A1, select B1 and enter =IF(AND(LEN(A1)=6,LEFT(A1,1)="1"),"2"&RIGHT(A1,5),A1). Adjust A1 if your data starts in another cell.

2
Fill down

Drag the fill handle from the bottom-right corner of B1 down alongside the populated cells in column A.

3
Check the results

Compare the original values in column A with column B. For example, 122811 should become 222811, while 105440 should become 205440.

4
Replace the originals if needed

Select and copy the results in column B, then select A1 and use Home > Paste > Paste Special > Values to replace the original values without copying the formulas.

Use a Formula to Replace the Leading Digit
Check data types and blank rows: Changed results are returned as text, while nonmatching values retain their original type. A reference to an empty cell may return 0, so avoid filling the formula through blank rows unless you handle them separately.
WPS Spreadsheet

Change Leading Digits in WPS Spreadsheet

Use the same conditional formula in WPS Spreadsheet to change the first digit of matching six-digit values, then paste the results as values if needed.

  1. 1. Open the workbook: Open WPS Spreadsheet and use File > Open to select your workbook.
  2. 2. Enter the formula: If your first value is in A1, select B1 and enter =IF(AND(LEN(A1)=6,LEFT(A1,1)="1"),"2"&RIGHT(A1,5),A1).
  3. 3. Apply it to the column: Drag the fill handle on B1 down beside the populated source cells, then check the results.
  4. 4. Paste values if needed: Copy the result cells, select A1, and use Home > Paste > Paste Special > Values to replace the originals.
Change matching leading digits without replacing other occurrences of 1Open and edit Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and fill controlsWork with a free, lightweight Office suite
microsoft office alternative - wps office

Frequently Asked Questions

Will the formula change every 1 in a value?

No. It changes only the first digit, and only when the value has six digits and begins with 1. The remaining five digits are preserved.

What happens to values that do not match?

A populated value that is not six digits long or does not begin with 1 is returned unchanged. An empty source cell may return 0.

Why is the changed result stored as text?

The formula joins "2" to the last five digits with the & operator, which produces text. If you need numbers for calculations, convert the pasted results to numbers after checking them.

Can I use the formula with a different starting cell?

Yes. Replace both references to A1 in =IF(AND(LEN(A1)=6,LEFT(A1,1)="1"),"2"&RIGHT(A1,5),A1) with the cell containing your first value. The formula contains four A1 references in total; update all of them.