Excel

How to extract a portion of text from an Excel cell (as used for meta tags)

This is a trick I used to extract the content of a meta description tag in Excel.

Let’s say you have the following in cell A1:

<meta name="description" content="Official dealer of wooden garden furniture.">

You can use Excel’s search and mid functions to extract the sentence “Official dealer of wooden garden furniture.” (without quotes).

First, search for “description” by using this formula in cell B1:

=SEARCH("description",A1,1)

Next, search for the closing “>” by using this formula in cell C1:

=SEARCH(">",A1,B1)

Finally, use the mid function to extract the sentence by using this formula in cell D1:

=MID(A1,B1+22,C1-B1-23)

Extra tip: The reverse of this is recreating the code in Excel using the append function (&). Cell A1 would be:

<meta name="description" content="

Cell B1 would be:

Official dealer of wooden garden furniture.

Cell C1 would be:

">

Finally, cell D1 would tie it all together:

=A1&B1&C1

You can copy and paste as values to clean up the end result.