Use Excel IF to Detect Negative Numbers or Text Starting with a Minus Sign
Question details
Identify negative numeric values or text beginning with a minus sign and return -1 for a match or 0 otherwise.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet column may contain a mixture of numbers and text that need different checks.
- Observed behavior
- The desired formula returns -1 for a negative number or text starting with a minus sign, and 0 for other values.
Identify the first cell to check and choose an empty cell for the result. The examples below check A2 and can be adjusted to match your worksheet.
Check Both Numbers and Text with IF and ISNUMBER
Use this formula when the cells may contain either numeric values or text.
Select an empty cell, such as B2, and enter =IF(ISNUMBER(A2),IF(A2<0,-1,0),IF(LEFT(A2,1)="-",-1,0)).
Press Enter, then drag the fill handle from B2 down the column to check the remaining cells.

Check a Column Containing Only Numbers
Use a simple numeric comparison when all values being checked are numbers.
Check Text for a Leading Minus Sign
Use LEFT when the values being checked are text.
Detect Negative Numbers and Minus-Sign Text in WPS Spreadsheets
Use IF, ISNUMBER, and LEFT in WPS Spreadsheets to check mixed numeric and text values and return a consistent result.
- 1. Open your spreadsheet: Open WPS Spreadsheets and select Open to load your workbook.
- 2. Enter the formula: Select B2 and enter =IF(ISNUMBER(A2),IF(A2<0,-1,0),IF(LEFT(A2,1)="-",-1,0)).
- 3. Fill the formula down: Press Enter, then drag the fill handle from B2 down to check the other rows.
- 4. Save the workbook: Select Menu > Save As and choose an Excel workbook format if you need to share the file with Excel users.

Frequently Asked Questions
Why doesn't =IF(A2="-*",-1,0) match text starting with a minus sign?
In a direct IF comparison, the asterisk is treated as a literal character, not a wildcard. Use =IF(LEFT(A2,1)="-",-1,0) to check the first character.
Can COUNTIF detect text that starts with a minus sign?
Yes. Use =-COUNTIF(A2,"-*") to return -1 when text in A2 starts with a minus sign and 0 otherwise. The asterisk is a wildcard in the COUNTIF criterion.
What does the tilde mean in the COUNTIF criterion "-~*"?
The tilde escapes the asterisk, so "-~*" matches the literal text -* rather than any text beginning with a minus sign. Use "-*" for the wildcard match.
Will the combined formula detect a negative number formatted without a minus sign?
Yes. ISNUMBER identifies the numeric value, and the formula checks whether it is less than zero, regardless of how the cell displays it.




