Look at font color and take action

  • Thread starter Thread starter troy_lee
  • Start date Start date
T

troy_lee

I have a spreadsheet maintained by another user. She has colored fonts
on certain line items. What I would like to do is to search row-by-row
to determine if the row has colored fonts (only two font colors are
used) and if it does I would like to cut the row and paste it into the
next available row on Sheet 2.

Thanks in advance for the help.

Troy
 
Troy,

Select a cell with the font color that you want to have moved, and run the macro below. I have
assumed that the font color change consistently is used in one column.

HTH,
Bernie
MS Excel MVP

Sub MoveRowsBasedOnFontColor()
Dim myColor As Variant
Dim myR As Long
Dim myC As Integer

myColor = ActiveCell.Font.ColorIndex
myC = ActiveCell.Column

For myR = Cells(Rows.Count, myC).End(xlUp).Row To 2 Step -1

If Cells(myR, myC).Font.ColorIndex = myColor Then
Cells(myR, myC).EntireRow.Cut _
Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp)(2).EntireRow
Cells(myR, myC).EntireRow.Delete
End If
Next myR

End Sub
 
Back
Top