Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Move chart to a separate worksheet in Excel
  • Conflicting Multiple Conditional Formatting Rules in Excel
  • Add Outline to Data in Excel
  • Number and Text Filters Examples in Excel
  • How To Compare Two Lists in Excel

References

  • Convert text string to valid reference in Excel using Indirect function
  • How to use Excel VLOOKUP Function
  • Count rows with at least n matching values
  • Complete List of Excel Lookup and Reference Functions, References and Examples
  • Extract all partial matches in Excel

Data Validations

  • Excel Data validation no punctuation
  • Excel Data validation number multiple 100
  • Excel Data validation specific characters only
  • Excel Data validation allow uppercase only
  • Excel Data validation don’t exceed total

Extract word that begins with specific character in Excel

by

To extract words that begin with a specific character, you can use a formula based on six functions: TRIM, LEFT, SUBSTITUTE, MID, LEN, and REPT. This approach is useful if you need to extract things like a Twitter user name from a cell that contains other text.

Formula

=TRIM(LEFT(SUBSTITUTE(MID(text,FIND("@",
txt),LEN(text))," ",REPT(" ",100)),100))

Note: 100 represents the longest word you expect to find that begins with the special character. Increase or decrease to suit your needs.

Worked Example:   How to count total words in a cell in Excel

Explanation

In the example shown, the formula in C5 is:

=TRIM(LEFT(SUBSTITUTE(MID(B5,FIND("@",
B5),LEN(B5))," ",REPT(" ",100)),100))

How this formula works

Starting from the inside out, the MID function is used to extract all text after “@”:

MID(B5,FIND("@",B5),LEN(B5))

The FIND function provides the starting point, and for total characters to extract, we just use LEN on the original text. This is a bit sloppy, but it avoids having to calculate the exact number of characters to extract. MID doesn’t care if this number is bigger than the remaining characters,  it simply extracts all text following “@”.

Worked Example:   Find longest string in column in Excel

Next, we “flood” the remaining text with space characters, by replacing any single space with 100 spaces using a combination of SUBSTITUTE and REPT:

SUBSTITUTE("@word and remaining 
text"," ",REPT(" ",100))

This seems crazy, but the logic becomes clear below.

Worked Example:   How to get top level domain (TLD) in Excel

Next, to extract just the word we want (i.e. @word), we use LEFT to extract the first 100 characters from the left. This gets us “@word”, plus many extra spaces. To visualize, the hyphens below represent spaces:

@word———————

Now we just need to remove all extra spaces. For that, we use the TRIM function.

 

Post navigation

Previous Post:

Put names into proper case — Manipulating NAMES in Excel

Next Post:

Create One-dimensional and Two-dimensional Array

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • Nested IF function example in Excel
  • AND function: Description, Usage, Syntax, Examples and Explanation
  • OR function Examples in Excel
  • How to return blank in place of #DIV/0! error in Excel
  • Not Equal To ‘<>‘ operator in Excel

Date Time

  • Calculate days remaining in Excel
  • How to calculate Quarter of Date in Excel
  • Basic Overtime Calculation Formula in Excel
  • Check If Two Dates are same month in Excel
  • Find Last Day of the Month in Excel

Grouping

  • Group numbers with VLOOKUP in Excel
  • If cell contains one of many things in Excel
  • Running count group by n size in Excel
  • How to randomly assign people to groups in Excel
  • Group times into 3 hour buckets in Excel

General

  • AutoFit Column Width, AutoFit Row Height in Excel
  • Excel Operators
  • Mark Workbook as Final in Excel
  • Freeze and Unfreeze Panes in Excel
  • 44 Practical Excel IF function Examples
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning