Look at font color and take action

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
 
B

Bernie Deitrick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

font color 3
Changing color 9
Macro changes color 3
Numbering based on row color 1
Font colors 2
Transfer background color when necessary 2
Filter by font colour 2
Row Color 7

Top