Excel if character is a number

Return to Excel Formulas List

Download Example Workbook

Download the example workbook

This tutorial demonstrates how to check if a cell is a number or text in Excel and Google Sheets.

cell is number text Main Function

Check Cell for Number or Text

We can check if a cell is a number by using the ISNUMBER Function or check if a cell is text with the ISTEXT Function.

ISNUMBER Function

The ISNUMBER Function checks if a value is a number. It returns TRUE if the value is a number and FALSE if it’s not.

=ISNUMBER(B3)

ISNUMBER

Knowing if a cell value is a number helps avoid errors when working with formulas. Numbers are sometimes stored as text, i.e. B4 (5000) in the example above, and that can result in errors in formulas referencing that cell.

In this example, the date, phone number, and time values all returned TRUE. These are regarded as numeric values in Excel and Google Sheets.

ISTEXT Function

The ISTEXT Function checks if a cell is text. It returns TRUE if the value is a text string and FALSE if it’s not.

=ISTEXT(B3)

ISTEXT

In this example, although the value in B5 (2350) is a number, it’s written within quotes and therefore stored as a text string. That’s why it returns TRUE.

Check if Cell is a Number or Text in Google Sheets

These formulas (ISNUMBER and ISTEXT) work exactly the same in Google Sheets as in Excel.

cell is number text Google Function

I have to find out if my cells text is a numeric value and wanted to use an elegant non VBA method that doesn’t impede on its current state or value.

What I’ve found is that the ISNUMBER() function only works if the cells are number formatting or has no spaces if text formatting e.g.:

number as text examples

For the first three I’ve used =ISNUMBER(...) and my last attempt is =ISNUMBER(TRIM(...)).

The only method I’ve used that doesn’t use VBA is to override my current values using text to columns then use the =ISNUMBER() function.

Note: I am proficient with VBA and Excel and understand I could create a user-defined function. But I don’t want to as this imposes a macro required workbook or an add-in to be installed, which I can and have done in some cases.

I will appreciate any advice, thoughts (even if they tell me it can’t be done) or VBA solutions (won’t be marked as answer however).

asked Apr 30, 2013 at 1:05

glh's user avatar

5

Try multiplying the cell value by 1, and then running the IsNumber and Trim functions, e.g.,:

=IsNumber(Trim(A1)*1)

answered Apr 30, 2013 at 1:10

David Zemens's user avatar

3

Assuming the value you want to convert is in A1 you can use the following formula:

=ISNUMBER(VALUE(TRIM(CLEAN(A1)))

Here the functions clean and trim are removing whitespace and none printable characters. The function value converts a string to a number, and with the converted string we can check if the value is a number.

answered Apr 30, 2013 at 2:02

Sam Plus Plus's user avatar

1

The shortest answer I’ve got to my question is:

=N(-A1)

Thanks brettdj

answered Apr 30, 2013 at 12:03

glh's user avatar

glhglh

5131 gold badge4 silver badges12 bronze badges

I know this post is old but I found this very useful in this case
I had a formula that returned (333), even though it is a number and ISNUMBER will say it is a number even though I did not want an answer if it had characters other than digits. The following worked for me.

=IF(AND(ISNUMBER(--(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))),"Is Number","")

It works if there is ANY characters other than digits. If you just want a true false drop the IF

=AND(ISNUMBER(--(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))))

As David Zemens stated

=IsNumber(Trim(A1)*1)

Works but if there is a «-» or the number is in parentheses it will say it is a number.

I hope this helps you or others.

answered Apr 8, 2016 at 18:14

Mouthpear's user avatar

MouthpearMouthpear

511 silver badge5 bronze badges

if anyone needs to filter cells that contain anything that is not numeric:

=AND(SUMPRODUCT(--ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))=LEN(A1),A1<>"")

decimals and negatives result FALSE

answered Oct 6, 2017 at 7:58

robotik's user avatar

I’m pretty late to the party, but, possibly the easiest, or shortest genuine test (note that the N function converts the number) is =ISNUMBER(--A1).

Using the examples you posted above…

Testing values using ISNUMBER

As with a lot of Excel shortcuts, the ‘—‘ forces Excel to assume the value afterward is a number, then all spaces are ignored. It’s as if you had typed --123 directly into a box (— obviously gives a positive number).

The third example also shows that other textual values in the string don’t simply cause an error output for ISNUMBER.

Number ISNUMBER() Format Comments
123456 TRUE Numeric Plain number
123456 TRUE Text Number as text
123456A FALSE Text Number with ‘A’ tagged on the end
123456 TRUE Text Number prefixed with four spaces

answered Mar 11, 2022 at 16:48

Paul's user avatar

PaulPaul

1239 bronze badges

Check If Character Is A Letter Or A Number — Excel

Hey all,

I have a cell range that is passed as a String to a function, and within that function I need to extract only the Column letter. If it was just 1 letter it would be simple, but it may be 2, so does anybody know of a way of testing to see if the second character is a letter or a number?

Thanks.

Excel VBA Course

Excel VBA Course — From Beginner to Expert

200+ Video Lessons
50+ Hours of Instruction
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

(80% Discount Ends Soon!)

View Course


Similar Topics



Hi,

I have a long list of data validation. I was wondering if there is a way when I clik on the drop down menu and type the first letter, automatically Excel shows all list with that letter.

Right now, I have to click on the drop down menu and scroll manually until I reach that desired list.

Thanks.

View Answers


This formula should be very often to use, but i cant found it anywhere, so i ask this here

For example in a1 is :
mike is playing basketball, he is very great player

i want to make it in b1 to be uppercase only in first letter so :
Mike is playing basketball, he is very great player

i know about proper formula =proper(a1) , but proper formula is make uppercase to all first letter in all words, we just need first letter in first words to be uppercase (and to every first words after dot if it can)

View Answers


when I type a number or letter into a cell and then press enter the cursor
jumps way down the page to what appears to be a random cell. The one i
originaly typed in remains blank. spreadsheet was previously ok this has
just started to happen.

help please
thanks

View Answers


Hi All,

If I drag a formula to the right it adapts the column letter in the formula from A to column B, which is standard Excel functionality.

However, if I drag the formula to the right I want Excel to skip a column each time.

In other words:

=A1 ; = B1 ; = C1

Should be

=A1 ; = C1 ; = E1 etc…

Is there an easy trick to do this?

Thanks,

Michiel

View Answers


Hello All

I wonder if you could help with this one, I have a list of data like this (no spaces or other characters)

JN551122B

What I need to do is split each of the characters in to its own cell

if JN551122B was in cell A1 I’d want to return:

B2 C2 D2 E2 F2 G2 H2 I2 J2
J N 5 5 1 1 2 2 B

The nearest I have got is the right function, but it brings over the preceeding characters, and I need each character in its own cell. Hopefully I could copy/paste a formula and change the reference for each cell value, i.e. 1 would return J, 2 = N, 3 = 5, 4 = 5 etc.

Thanks for your help!

View Answers


Since there isn’t a ISDATE function in excel.

The following can be used to simulate the same, and avoid having to achieve the same with VBA’s IsDate function:

STEPS:
1- Format the column (ex A) as text

2- Formula to check for valid dates:
=ISERROR(DATEVALUE(A1))

View Answers


I have a large database with names, addresses etc. When I try to make changes
to the email address, like change the font color or change on letter, Excel
tries to email the address. If I click in the formula bar to make the
changes, it automatically changes it back to all blue text and underlined. I
have tried to format all of the cells as «Text» to show as entered, but it
doesnt work. PLEASE HELP

View Answers


Hi all,

Probably a simple little function, help would be appreciated!

I’d like to take a number entered into one cell ie. A1 = 20

and split it randomly but evenly over 3 other cells ie.
B1=6
C1=8
D1=6

Number should be whole and no zeros?

Thanks all!

View Answers


Hello

I have several rows of text data, the first 17 characters of which are in this format (4 letters_-_DD.MM.YYYY

It’s then followed by a variable number of characters i.e.

ABCD — 01.02.2003 ABCDEFG HIJ KLMNO

I would be grateful for a formula that will delete all characters to the right of the 17th character (i.e. the ‘3’).

Many thanks!

View Answers


Hi,
I am looking for a method/formula that will reverse multiple text entries from «abcde» to «edcba». The entries are composed of several words that need to be reversed ie from «ab cde fg» to «gf edc ba»

Thanks

View Answers


I need to create a IF statement where it will count the character length and if not 6 then add leading zeros to field to make a fixed 6 character length .. so if field is 489 then the if statment would make it 000489

View Answers


Hi all —

Im very familiar with how to write a macro to automatically autofilter a list based upon a Cell Value (i.e. Range =(A1)…etc.)…. but what I cannot figure out how to correctly write is a way to have Excel automatically autofilter a list for any row that CONTAINS the Cell Value, instead of just the exact value.

Cell Value = «birds»
Example — I need to filter every row so that I see every row that CONTAINS «birds» in the character-string, not just the row that = «birds».

a) is this possible?

If not, I’d like to know also so I can stop attempting to guess (-;
Thanks!!!

Matt

View Answers


I have a spreadsheet counting down the days until a date is reached. However, after that date is reached and passed I get a #NUM! error.

What can I do to countdown the days as below AND countdown the days that have passed as a NEGATIVE NUMBER???

=DATEDIF(NOW(),D11,»D»)

View Answers


Hi folks,

Hoping someone can help me quickly as I’m pulling my hair out and have a deadline getting too close.

Been trailing the net and this board but can’t work out how to do a simple variance.

How do I work out the difference between two numbers — including negatives.

If the numbers are all positive, it’s fine as it’s simply a case of A — B = C which is your difference. However, that doesn’t work if B is negative.

I need a formula that would give the following:

First Number / Second Number / Difference
1 / 5 / 4
1 / -5 / -6
-1 / 5 / 6
-1 / -5 / -4
-5 / -1 / 4

Hopefully there’s a simple function I’ve been missing.

Thanks in advance, R

View Answers


I need to insert a «.» into a column of cells. What is the best way to do this?

Example: Existing data 1000UG01
Needs to be 1000UG.01

Existing cells are all the same length and the «.» needs to be inserted in the same place.

Thanks in advance for any help.

View Answers


Posted this on the Ozgrid forums, but haven’t gotten any help yet, so I thought I’d try here too!

I’ve been having a strange problem lately. I have a fairly lengthy macro that works perfectly most of the time. Occasionally it will run as expected but as soon as the macro ends, excel becomes unresponsive to mouse-clicks. When I click anywhere (trying to select a cell, or an excel menu item…clicking anywhere in excel) I’ll get the a ‘ding’ system sound and nothing will happen. BUT, if I use the keyboard arrow keys, I can see that the active cell selection moves accordingly. Then it gets really strange — when I have a cell highlighted and press any key to input text, it gets duplicated. So if I press «s’ it will input «ss» into the cell, and then when I press enter it will auto-move to the next cell down, but nothing ends up getting saved into the previous cell.

I don’t understand what’s going on at all. I can’t think of anything in my macro that would have these kinds of effects. I’ve made sure that screenupdating is turned back on at the end of every procedure. If I go into the VBE, I can manually run procedures and they all work fine. The only way I’ve been able to get back to normal is by force closing excel altogether and re-opening. Any ideas?

______________________

Still having trouble, and the same thing is happening with this workbook on two different computers, so I don’t think it’s a hardware, or OS specific issue. When it gets locked up like this, I can still do anything in the VBE (edits cells, run macros, etc.) with no problems. If I’m in the excel window, I can click alt on the keyboard and the shortcut keys for the menu come up, but I can’t go deeper than that by clicking the letter shortcuts, they do nothing. If I use the delete key to delete the contents of a cell, then it gets deleted. But if I type anything else (numbers, letters, or symbols) then it types 2 instances of the key every time, yet when I hit enter, nothing changes in the cell. I also can’t really bring focus to the excel window if something else (ie. the VBE) is on top of it, clicking into the excel window just gives the little system ‘ding’ sound and nothing happens.

If I hit the save button in the VBE (since I can’t click anything in the excel window), then it seems to snap out of it and go back to normal. I tried searching for anything simmilar to this and can’t find anything…

Any help would be much appreciated. This is driving me nuts!

View Answers


Good day… I need an IF Function that will allow me to action a time in a time range:

… If the time 04:16 falls in the time range 04:00 — 04:29, than put a one (1) in the filed x…
… If the time 04:16 doesn’t fall in the time range 04:00 — 04:29, than leave the x fiel empty

Any help is appreciated.

View Answers


Good afternoon,

Is there a way to enter a colon into a standard number to create a value that can be formatted into a 24 hour time value ?

eg a time is listed as 1345 with a general number format, and I want it returned as 13:45 witha custom format of hh:mm.

Other than creating a table and using a vlookup function, I am hoping there is a better way?

Darren

View Answers


Hi

I am looking for a formula to remove special characters and spaces from a cell

I have been using «substitute» but this requires me to know which character I want to remove and this isn’t always known

I have tried looking at some macro solutions but became lost quite quickly

Any help would be much appreciated

Thanks

View Answers


I have cells in a column, some colored yellow, some not. I am trying to use
the SUMIF function to sum only the cells in the range that are colored. Can
this be done? Can I enter something in the «criteria» part of the formula
that can do this?

=SUMIF(D3:D13,»criteria»,D3:D13)

I also tried to use the CELL function’s color feature, but I couldn’t get it
to work right. I don’t know how to get Excel to recognize if a cell is
colored in a formula.
=CELL(«color»,cell)

It might just be that I don’t know what this means in Help:

«color» —> 1 if the cell is formatted in color for negative values;
otherwise returns 0 (zero).

Can anyone help?

View Answers


Let’s create a function to convert the text to the new format, with a Sub to run the loop. Then, let’s strip Diacritics from letters, and use a Switch Statement to check if a character is Number, Letter, or Other: (Note that, if the character is neither Number nor Letter, we don’t need to run an additional check to see if it is «anything else» — because, those are all that are left!)

Sub MyMacro()
    Dim rTMP As Range
    For Each rTMP In Range(Cells(1,1), Cells(Rows.Count,1).End(xlUp)).Cells
        rTMP.Offset(0,1).Value = TextToMask(rTmp.Value)
    Next rTMP
End Sub

Function TextToMask(Value As String) As String
    Const NumberValue AS String = "N"
    Const LetterValue AS String = "L"
    Const SymbolValue AS String = ""
    Dim i AS Long, CleanValue As String
    CleanValue = StripDiacritics(Value)

    If Len(Value)<1 Then Exit Function

    For i = 1 To Len(Value)
        Select Case Mid(CleanValue, i, 1)
            Case "0" To "9"
                TextToMask = TextToMask & Left(NumberValue & Mid(Value, i), 1)
            Case "A" To "Z", "a" To "z"
                TextToMask = TextToMask & Left(LetterValue & Mid(Value, i), 1)
            Case Else
                TextToMask = TextToMask & Left(SymbolValue & Mid(Value, i), 1)
        End Select
    Next i
End Function

Function StripDiacritics(Value As String) As Value
    'This will convert letters like "á" to "a", etc
    If Len(Value) < 1 Then Exit Function
    Dim i AS Long, Letters As Variant, Comparison As Variant
    Letters = Array("a","b","c","d","e","f","g","h","i","j","k","l","m", _
                    "n","o","p","q","r","s","t","u","v","w","x","y","z")
    
    For i = 1 To Len(Value)
        Comparison = Application.Match(Mid(Value, i, 1), Letters)
        
        If IsError(Comparison) Then
            StripDiacritics = StripDiacritics & Mid(Value, i, 1)
        Else
            StripDiacritics = StripDiacritics & Chr(Comparison - 1 + 
                IIF(Mid(Value, i, 1)=UCase(Mid(Value, i, 1)), Asc("A"), Asc("a")))
        End If
    Next i
End Function

Excel has a bunch of formulas and data analysts use this application to prepare various reports and dashboards. To support that analysis this article will help an excel user to identify all the cells whose values either starts with a number or an alphabet from a collection of dataset. We will identify these cells using the combination of following formulas.

  • IF function

  • ISERR function

  • Left function

Check if first character in a cell is a number or a letter

The following formulas can be used to check if the first character of a cell is number or a letter.

  • =IF(ISERR(LEFT(cell_location,1)*1),»Letter”, “Number»)

    In this formula, we are calculating the value of a cell’s left most character multiplied by 1. If the obtained value is not a number then it will return Letter else Number.

  • =IF(ISNUMBER(VALUE(LEFT(cell_location, 1))),»Number», «Letter»)

    In this formula, we are calculating the value of left most character of a cell. If the returned value is a number, then it will return TRUE (by default) or as per the defined value (Number in our case).

Step 1 − A sample worksheet has been shown below with some sample data.

Step 2 − Under the column C, the following formula has been used to get the desired result. Enter the formula in a cell and press enter.

=IF(ISERR(LEFT(B2,1)*1),»Letter”, “Number»)

Step 3 − Now drag the cell to copy the formula in other cells also to view the output against all cells. Enter the formula in a cell and press enter.

Step 4 − Under the Column D, the following formula has been used to get the desired result.

=IF(ISNUMBER(VALUE(LEFT(B2, 1))),»Number», «Letter»)

Step 5 − Now drag the cell to copy the formula in other cells also to view the output against all cells

Formula Syntax Description

Argument Description
IF(logical_test, {value_if_true},{value_if_false}
  • Logical_test specifies the condition basis which the data needs to be rendered.

  • Value_if_true specifies the value that shall be returned if the condition satisfies.

  • Value_if_false specifies the value that shall be returned if the condition does not satisfy.

LEFT(text, [num_chars])
  • Text specifies the cell address whose value to be returned or scanned from left.

  • num_chars specifies the number of characters from left that need to be returned/scanned.

ISERR(value)
  • The ISERR function returns TRUE for any error type except the #N/A error. For example, #REF!, #DIV?0!, #VALUE!, #NAME? etc. ISERR function can be used with the IF function to test for an error, display a custom message, or for a different calculation if found.

  • (value) points to the value of the selected cell where the error to be identified.

Conclusion

The start or end character of a cell value can be identified using many other combinations of excel functions. However, these the most used functions for the same. The same functions can be used to identify the cell ending with a number or letter by replacing LEFT from RIGHT.

  • =IF(ISERR(RIGHT(cell_location,1)*1),»Letter”, “Number»)

  • =IF (ISNUMBER(VALUE(RIGHT(cell_location, 1))),»Number», «Letter»)

Понравилась статья? Поделить с друзьями:
  • Excel if cells do not contain text
  • Excel if cells contains value
  • Excel if cells contain numbers
  • Excel if cells are different
  • Excel if cell value not in range