Excel 2007 code to Select Colored Text

Microsoft Microsoft office excel 2007 ac...
June 24, 2010 at 11:37:21
Specs: Windows XP
Hello, I am trying to program excel 2007 to select the cell with blue text from any given row within my spreadsheet and then paste this cell into a cell in another spreadsheet. Any ideas on how to code this in VBA would be much appreciated! Thanks

See More: Excel 2007 code to Select Colored Text

Report •

#1
June 24, 2010 at 21:23:15
re: Any ideas on how to code this in VBA...

With the limited information you have provided, an "idea" is about all we can offer.

We don't know what you mean by any given row nor do we know where you want the cell pasted other than in another spreadsheet.

This "idea" will search Row 1 and copy the first cell whose Font color is Blue to Sheet2!A1.

Option Explicit
Sub FindBlueCell()
Dim myCell As Range
 For Each myCell In Rows(1).Cells
    If myCell.Font.ColorIndex = 5 Then
       myCell.Copy Destination:=Sheets(2).Cells(1)
       Exit For
    End If
 Next
End Sub

Note: This code will copy the first cell whose font color has been set to blue. It will not copy a cell whose font color is blue because of Conditional Formatting.

If you'll provide us with some more details, we might have some other "ideas".


Report •
Related Solutions


Ask Question