Excel 與 Google Sheets 將文本數字轉換為數值:5 種方法

SUM 忽略資料、查詢失敗或排序異常時,用 ISTEXT 與 ISNUMBER 檢查。左對齊和綠色三角只是線索。把格式改成“數字”不會自動轉換已有文本;先備份原始資料。

本文目錄

快速解答

SUM 忽略資料、查詢失敗或排序異常時,用 ISTEXT 與 ISNUMBER 檢查。左對齊和綠色三角只是線索。把格式改成“數字”不會自動轉換已有文本;先備份原始資料。

=--A2

檢查重點

方法包括錯誤提示中的轉換為數字、選擇性貼上乘 1、分列後完成、VALUE/雙負號/NUMBERVALUE 公式,以及定期匯入時使用 Power Query。根據資料規模、區域分隔符和更新方式選擇。

邊界與相容性

賬號、郵編、前導零與超過 15 位的標識往往應該保持文本。處理貨幣符號、不間斷空格、千位符和小數符時先明確規則。Google Sheets 的 VALUE 也受區域設定影響,不要把無法安全解釋的資料強制變成數值。

完整英文範例、公式與作者備註

Tested in: Live formula checks in Microsoft Excel 16.114.4 for Mac (English UI; system region zh-Hans_US), November 8, 2026; Google Sheets (spreadsheet locale zh_CN), November 9, 2026. Results and platform differences are noted below; this is not a certification of every menu workflow.

Which versions this applies to

  • Excel for Microsoft 365, 2024, 2021, 2019, 2016 (Windows): All five methods. NUMBERVALUE is listed for Excel 2016 and later on Microsoft’s page.
  • Excel for Mac and Excel for the web: Methods 1, 2 and 4. Microsoft’s convert-to-number page covers Windows and web.
  • Google Sheets: Method 4 (formulas) plus the Sheets section below. Sheets has no green-triangle warning.

How to tell a number is actually text

SignWhat to check
Green triangle in the top-left corner (Excel)Hover the icon: “Number Stored as Text”
Values sit on the left of the cellReal numbers align right unless someone changed the alignment
SUM returns too little, or 0=COUNTA(A2:A100)-COUNT(A2:A100) counts non-numeric cells
Status bar shows Count but no SumSelect the range and look at the bottom bar
Lookups return #N/A for visible values=ISTEXT(A2) is TRUE on one side and FALSE on the other
Sorting puts 100 before 25Text sorts character by character

The difference between + and SUM explains a lot of confusion. In our LibreOffice check, =SUM(A2:A2) on a text “00123” returned 0, while =A2+0 returned 123: arithmetic operators convert text, while SUM skips text in a range. That’s why one total in your report can be right and another wrong.

Why it happens

  • The column was formatted as Text before the data went in. Microsoft documents that if you format a cell as Text, type a number, and then change the format to Number, the cell stays text. Changing the format alone doesn’t convert anything.
  • Leading apostrophe. '1003 forces text on purpose.
  • Imports and exports. CSV files, ERP and banking exports, and copied web tables.
  • Formulas that return text. LEFT, MID, RIGHT, TEXT, TRIM, SUBSTITUTE and & always return text, even when the result looks like a number. =LEFT("2026-INV",4) is the text “2026”.
  • Hidden characters. A non-breaking space or a tab glued to the number. See TRIM not working (CHAR 160).

Example data

Put these values in A2:A10. Every one of them is text:

A (text)Expected numberWhat’s wrong with it
2123123Normal spaces
300123123Leading zeros (is this a code? see “Hard cases”)
4$1,234.501234.5Currency symbol and thousands separator
545%0.45Percent sign
6(125)-125Accounting-style negative
7125--125Trailing minus (SAP and mainframe exports)
81.234,501234.5European separators
91 234 (non-breaking space)1234Character 160 inside the number
103 000 (normal spaces)3000Spaces as thousands separator

Method 1: Convert to Number (the green triangle)

  1. Select the cells. You can select the whole column, and the menu works on all flagged cells at once.
  2. Click the warning icon that appears next to the selection, or press Alt+Shift+F10, as Microsoft’s page suggests.
  3. Choose Convert to Number.

If you don’t see triangles at all, error checking may be off. Turn it on under File > Options > Formulas > Enable background error checking and make sure the rule Numbers formatted as text or preceded by an apostrophe is ticked.

Best for: clean digits that Excel already flagged. Won’t help with: rows 7–9 above, which Excel doesn’t recognize as numbers in the first place.

Method 2: Paste Special > Multiply by 1

Microsoft describes this as multiplying each cell by 1 to force the conversion. The value looks the same, but it’s now a number:

  1. Type 1 in an empty cell formatted as General and copy it (Ctrl+C).
  2. Select the text numbers.
  3. Home > Paste > Paste Special, choose Multiply, click OK.
  4. Delete the helper 1.

This converts the cells in place, with no helper column. Choosing Add with an empty copied cell (adding 0) is a common variation.

Method 3: Text to Columns > Finish

Select a single column, then go to Data > Text to Columns and click Finish straight away. Excel re-enters every cell and converts anything that looks like a number. Microsoft’s #N/A troubleshooting page recommends this for mismatched number and text values.

Text to Columns has a less-known option for trailing minus signs (row 7). Click Next twice, then Advanced, tick Trailing minus for negative numbers, and also set the decimal and thousands separators to match your data (useful for row 8). Then click Finish.

Watch out: It works on one column at a time and overwrites the column to its right if you accidentally choose a delimiter.

Method 4: Formulas (VALUE, --, NUMBERVALUE)

A formula is the only method that can also clean the text on the way. Put it in a helper column, then copy and use Paste Special > Values over the original.

FormulaWhat it doesNotes
=--A2Double negation forces a numberShort. Same results as VALUE in our checks
=VALUE(A2)Converts text that “looks like” a number, date or timeMicrosoft notes it’s rarely needed because Excel converts automatically
=A2*1 or =A2+0Arithmetic coercionSame as --
=NUMBERVALUE(A2,",",".")Converts with the separators you specifyIgnores spaces, even in the middle (“3 000” → 3000). Locale-independent

Results in LibreOffice 25.2 (en-US) for the example rows. VALUE, -- and *1 gave identical results on every row:

RowVALUE / --NUMBERVALUE(A2)Fix if it fails
123123123—
00123123123Should it be a number at all? See “Hard cases”
$1,234.501234.5#VALUE!Mac Excel NUMBERVALUE: 1234.5
45%0.450.45—
(125)-125#VALUE!Mac Excel NUMBERVALUE: -125
125--125 in LibreOffice#VALUE!Mac Excel returned #VALUE!; use the explicit parsing formula below
1.234,50#VALUE!#VALUE!, but 1234.5 with NUMBERVALUE(A8,",",".")NUMBERVALUE with separators
1 234 (char 160)#VALUE!#VALUE!SUBSTITUTE first
3 000 (normal spaces)#VALUE!3000NUMBERVALUE, or remove the spaces

No single function handles everything. Use -- for clean digits, NUMBERVALUE for spaces and foreign separators, and a SUBSTITUTE for anything with hidden characters.

Trailing minus:

=IF(RIGHT(A7)="-",-LEFT(A7,LEN(A7)-1),--A7)

Non-breaking space inside a number: remove it (replace with nothing, not a space), then convert:

=--SUBSTITUTE(A9,UNICHAR(160),"")

Everything at once: strip spaces of both kinds, then convert. Errors become blank so you can spot rows that need a manual look:

=IFERROR(--SUBSTITUTE(SUBSTITUTE(TRIM(A2),UNICHAR(160),"")," ",""),"")

Don’t use N() for this. =N("123") returns 0, not 123. N passes numbers through and turns text into 0.

Empty cells: results vary. Microsoft documents that NUMBERVALUE("") returns 0. In LibreOffice, NUMBERVALUE of an empty cell returned #VALUE!, while VALUE and -- of an empty cell returned 0. Neither is what you want in a data column, so guard blanks with IF(A2="","",…) and empty rows stay empty.

Method 5: Power Query (for files you import every week)

If the same export arrives every week, fix the type once in Power Query: Data > From Table/Range, select the column, set Data Type to Decimal Number or Whole Number, and choose Close & Load. Next week, replace the source file and click Refresh. If some rows fail to convert, Power Query marks them as errors, so you can see exactly which rows are bad instead of having them silently ignored.

Google Sheets

Sheets doesn’t flag text numbers, so check with =ISTEXT(A2) or =COUNTA(A2:A)-COUNT(A2:A).

  • Formula: =VALUE(A2). Google’s documentation says VALUE converts any date, time or number format Sheets understands, and shows an error when it can’t. =--A2 works too. For a whole column in one cell:
=ARRAYFORMULA(IF(A2:A="",,VALUE(SUBSTITUTE(A2:A,CHAR(160),""))))

Then copy the result and use Edit > Paste special > Values only (Ctrl+Shift+V) over the original.

  • Format > Number > Plain text is the Sheets equivalent of Excel’s Text format. Numbers typed into those cells stay text. Switch the format back to Automatic before re-entering data. Formatting alone does not reliably convert existing text; re-enter or parse it and verify with ISNUMBER.
  • European separators: Sheets’ VALUE uses the spreadsheet’s locale (File > Settings > Locale). For text from another locale, swap the separators with SUBSTITUTE first: =VALUE(SUBSTITUTE(SUBSTITUTE(A8,".",""),",",".")) in a US-locale sheet.
  • Why it matters more in Sheets: QUERY uses the majority data type in each column and treats the minority as null, so a few text numbers can disappear from QUERY results. See FILTER vs QUERY.

Hard cases: when NOT to convert

  • Codes with leading zeros (ZIP codes, employee IDs, SKUs like 00123). Converting turns 00123 into 123. Keep these as text, and convert the other side of a lookup to text instead (see XLOOKUP #N/A fixes). If you want the digits stored as numbers but displayed padded, use a custom format such as 00000.
  • Numbers longer than 15 digits (card numbers, some tracking and IMEI numbers). Microsoft’s specifications list Excel’s number precision as 15 digits, so converting 1234567890123456789 to a number changes the trailing digits to zeros. These must stay text.
  • Dates stored as text. VALUE converts them to serial numbers, but whether “03/04/2026” means March 4 or April 3 depends on your locale. Use the dedicated guide: Excel dates stored as text.

Common mistakes

  1. Changing the number format and expecting a conversion. Microsoft confirms that the cell stays text. Re-enter the values with one of the five methods.
  2. Clicking “Ignore Error”. It hides the triangle, not the problem.
  3. Using N() to convert. It returns 0 for text.
  4. Converting codes and long IDs. You lose leading zeros and digits after the 15th.
  5. Leaving the helper formulas in place. Paste values back over the original, or every report has to point at the helper column.

FAQ

How do I convert text to numbers in Excel quickly?

Select the cells, click the green warning icon and choose Convert to Number. If there is no icon, use Data > Text to Columns > Finish on the column, or Paste Special > Multiply by 1.

What’s the difference between VALUE and double negative (—)?

Both convert text that looks like a number into a number, and both return #VALUE! for text they can’t read. VALUE is easier to read. — is shorter and common inside bigger formulas such as SUMPRODUCT.

Why does changing the format to Number not work?

The format only changes how a value is displayed. Microsoft documents that a cell formatted as Text keeps its text value after you switch to Number. Re-enter it with Convert to Number, Text to Columns or a formula.

How do I convert numbers with commas as decimal separators?

Use NUMBERVALUE and specify the separators: =NUMBERVALUE(A2,”,”,”.”) converts “1.234,50” to 1234.5 regardless of your Excel locale.

How do I convert text to numbers in Google Sheets?

Use =VALUE(A2) or =—A2 in a helper column, or =ARRAYFORMULA(IF(A2:A="",,VALUE(A2:A))) for the whole column. Then paste the results back with Paste special > Values only.

Live-test findings

The table above preserves the labelled LibreOffice baseline; it is not an Excel result table. On Excel 16.114.4 for Mac, NUMBERVALUE returned 1234.5 for $1,234.50, -125 for (125), and #VALUE! for 125-. Data-menu entries for Text to Columns and Get Data (Power Query) were present, but Advanced separators and Using Locale were not tested end to end.

Sources

Oscar

專注電子表格公式與排錯;具體測試環境和待驗證事項見各篇文章。

Tested in Microsoft Excel 16.114.4 for Mac (English UI; system region zh-Hans_US), November 8, 2026; Google Sheets (spreadsheet locale zh_CN), November 9, 2026.

本主題下一篇:資料清理與錄入 Google Sheets 跨兩列標記重複值:條件格式