Separating Cells Based on Text Color

Written by Allen Wyatt (last updated March 25, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Thomas has a column that contains nothing but text values, such as sentences and phrases. Some cells show their text in red and the rest are in black. He would like a way to separate the text such that black-text cells remain in the column and red-text cells are moved to the next column.

There are a couple of ways you can approach this issue. Perhaps the easiest approach is to simply sort or filter the column that has the text values in it. Excel allows you to filter and sort based on text color, which means that either you could see just the red-text cells or put all the red-text cells into a contiguous range. Then it is an easy task to cut the red-text cells and paste them into the next column.

For instance, here's how you would do the sort:

  1. Select the cells that contain your text values.
  2. Display the Data tab of the ribbon.
  3. Click the Sort tool in the Sort & Filter group. Excel displays the Sort dialog box.
  4. Using the Sort On drop-down list, choose Font Color.
  5. Use the Order drop-down list to indicate which color you want to be shown first in the sorted list. (This is where you would pick your red color. The drop-down list includes each color detected in the range you selected in step 1.)
  6. Click on OK.

Now your cells are sorted, by color, with the color specified in step 5 at the beginning of the cell range. You can easily copy it or move it to a different column. You could use the same general steps if you wanted to filter your text values based on font color.

If you prefer, you could also use a macro to move your red-text cells. Here's an example that copies the cell value and font color one cell to the right.

Sub MoveRedText1()
    Dim c As Range

    If Selection.Columns.Count > 1 Then Exit Sub

    For Each c In Selection
        If c.Font.Color = vbRed Then
            c.Offset(0, 1) = cell.Value
            c.Offset(0, 1).Font.Color = vbRed
            c.ClearContents
            c.Font.Color = vbBlack
        End If
    Next c
End Sub

To use the macro, just select the cells you want to analyze and then run the macro. It doesn't copy all formatting of the cells it is moving; if that is critical you can actually use a much simpler macro to do the moving.

Sub MoveRedText2()
    Dim c As Range

    For Each c In Selection
        If c.Font.Color = vbRed Then _
          c.Cut Destination:=c.Offset(0, 1)
    Next c
End Sub

If you use either of these macros and your red-text cells don't move, it could be because the cells don't actually use red text. There are many different shades of red that can be displayed in Excel, so you'll need to tweak the macros to make sure that you are checking for the proper font color.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12604) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Pasting Clean Text

One of the most helpful tools in Word is the ability to paste straight text into a document. This is used so much on my ...

Discover More

Printing a Bookmark List with Contents

Bookmarks can be a great tool in Word, allowing you to easily remember the location of desired blocks of text. If you ...

Discover More

Understanding a Style's Priority

Word allows you to assign priority values to individual styles. This tip explains what those values mean, along with how ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Sorting Decimal Values

Government and industrial organizations often use a numbering system that relies upon a number both before and after a ...

Discover More

Sorting Dates and Times

One of the strong features of Excel is its ability to sort information in a worksheet. When it doesn't sort information ...

Discover More

Sorting Letters and Numbers

Sorting information in a worksheet can be confusing when Excel applies sorting rules of which you are unaware. This is ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

2019-11-13 01:00:18

Nana Sagoe

I want to separate my data. But I used the styles at the home ribbon. Black cells for normal and red cells for bad.

What's the formula to separate them.


2018-07-17 21:33:13

Gregory

My problem is that I have one cell that has a persons name in blue, then no space followed by their job title in black text. How do I separate this data by color into two cells from one, starting with the data in one cell?

Bob SmithSenior Data Analyst

Bob Smith is in blue text, and Senior Data Analyst is in black text. How to get this done?


2018-05-14 11:17:16

Dave Bonin

I think for robustness, I would move all black items first.
I would assume everything that's left behind, ie: not black, was red.
Then I would move all of those.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.