TEXTBEFORE function
Summary
Returns text that occurs before a given character or string
Syntax
TEXTBEFORE(text,delimiter,[instance_num], [match_mode], [match_end], [if_not_found])
The TEXTBEFORE function syntax has the following arguments:
text The text you are searching within. Wildcard characters are not allowed. If text is an empty string, Excel returns empty text. Required.
delimiter The text that marks the point before which you want to extract. Required.
instance_num The instance of the delimiter after which you want to extract the text. By default, instance_num = 1. A negative number starts searching text from the end. Optional.
match_mode Determines whether the text search is case-sensitive. The default is case-sensitive. Optional. Enter one of the following:
• 0 Case sensitive.
• 1 Case insensitive.
match_end Treats the end of text as a delimiter. By default, the text is an exact match. Optional. Enter the following:
• 0 Don't match the delimiter against the end of the text.
• 1 Match the delimiter against the end of the text.
if_not_found Value returned if no
text The text you are searching within. Wildcard characters are not allowed. If text is an empty string, Excel returns empty text. Required.
delimiter The text that marks the point before which you want to extract. Required.
instance_num The instance of the delimiter after which you want to extract the text. By default, instance_num = 1. A negative number starts searching text from the end. Optional.
match_mode Determines whether the text search is case-sensitive. The default is case-sensitive. Optional. Enter one of the following:
• 0 Case sensitive.
• 1 Case insensitive.
match_end Treats the end of text as a delimiter. By default, the text is an exact match. Optional. Enter the following:
• 0 Don't match the delimiter against the end of the text.
• 1 Match the delimiter against the end of the text.
if_not_found Value returned if no
Example
=TEXTBEFORE(A2,"Red")
=TEXTBEFORE(A3,"Red")
=TEXTBEFORE(A3,"red",2)
=TEXTBEFORE(A3,"red",-2)
=TEXTBEFORE(A3,"Red",,FALSE)
=TEXTBEFORE(A3,"red",3)
=TEXTBEFORE(A3,"Red")
=TEXTBEFORE(A3,"red",2)
=TEXTBEFORE(A3,"red",-2)
=TEXTBEFORE(A3,"Red",,FALSE)
=TEXTBEFORE(A3,"red",3)