Excel Function: RIGHT

Purpose

The RIGHT function returns a subset of a text value’s characters, taken from its right-hand side.

Invocations of the RIGHT function take the form:

RIGHT(text,[num_chars])

Arguments

ArgumentArgument typeDescription
textMandatoryA text value whose rightmost characters will be returned.
num_charsOptional. Defaults to 1 if omitted.A number of characters to be returned from the right of the value passed to the text argument.

Related Functions

FunctionExamplePurpose

Error Conditions

Error valueCondition typeCondition
#VALUE!Bad argumentA negative number was supplied to the num_chars argument.
#VALUE!Bad argumentA value of type currency, geography, or stock was supplied to the text argument.

Examples

ExampleFormulaResultDescription
1=RIGHT("abcdef",0)Extract zero (0) of the rightmost characters from a text value.
  • An empty text value is returned.
2=RIGHT("abcdef",4)cdefExtract fewer characters from a text value than it contains.
  • RIGHT operates on “abcdef”.
  • It contains 6 characters.
  • RIGHT extracts 4 characters from it.
  • The text value “cdef” is returned.
3=RIGHT("abcdef",10)abcdefExtract more characters from a text value than it contains.
  • RIGHT operates on “abcdef”.
  • It contains 6 characters.
  • RIGHT attempts to extract 10 characters from it, but can only extract 6.
  • The text value “abcdef” is returned.
4=RIGHT(123.456,4).456Extract fewer characters from a positive number than it contains.
  • The number 123.456 is converted into the 7-character-long text value “123.456”.
  • RIGHT extracts 4 characters from it.
  • The text value “.456” is returned.
5=RIGHT(-123.456,4).456Extract fewer characters from a negative number than it contains.
  • The number -123.456 is converted into the 8-character-long text value “-123.456”.
  • RIGHT extracts 4 characters from it.
  • The text value “.456” is returned.
6=RIGHT(1E+5,2)00Extract the rightmost characters from a number expressed in scientific notation.
  • The number 1E+5 is converted into the 6-character-long text value “100000”.
  • RIGHT extracts 2 characters from it.
  • The text value “00” is returned.
7=RIGHT(DATE(2023,6,7),2)84Extract the rightmost characters from a date.
  • The date 7 June 2023 is converted into the 5-character-long text value “45084”.
  • RIGHT extracts 2 characters from it.
  • The text value “84” is returned.
8=RIGHT(TIME(18,0,0),2)75Extract the rightmost characters from a time.
  • The time 18:00:00 is converted into the 4-character-long text value “0.75”.
  • RIGHT extracts 2 characters from it.
  • The text value “75” is returned.
9=RIGHT("abcdef",-1)#VALUE!Extract a negative number of characters from a text value.
  • Extracting a negative number of characters from a text value is nonsensical.
  • The error value #VALUE! is returned.

Examples: Errors

ExampleValue supplied to “text” argumentResultDescription
1London#VALUE!Apply the RIGHT function to a stock value.
  • The stock value cannot be treated as a text value by the RIGHT function.
  • Because of this, the #VALUE! error value is returned.
2USD/GBP#VALUE!Apply the RIGHT function to a currency value.
  • The currency value cannot be treated as a text value by the RIGHT function.
  • Because of this, the #VALUE! error value is returned.
3MICROSOFT CORPORATION (XNAS:MSFT)#VALUE!Apply the RIGHT function to a geography value.
  • The geography value cannot be treated as a text value by the RIGHT function.
  • Because of this, the #VALUE! error value is returned.

These errors can be mitigated by converting values of type stock, currency and geography to text before passing them to the RIGHT function. I.e.:

=RIGHT(VALUETOTEXT(text),[num_chars])