Delete entire row based on cell color

G

Guest

Hello,

Could someone show me how to develop a macro that would delete an entire row
depending on the font color (ie: red) of text in column A.

Many thanks.

CMcK
 
J

John Coleman

This deletes row 5 if the font in column 1 (A) is red:

Sub test()
If Columns(1).Font.ColorIndex = 3 Then Rows(5).Delete
End Sub

HTH

-John Coleman
 
G

Guest

Thanks John. When I look at the line of code it looks extremely
straightforward. I just have difficulty putting together the correct syntax.
Your help is really appreciated - thanks again.

CMcK
 
J

John Coleman

You're welcome - I didn't completely know the answer until I decided to
reply. I turned on the macro recorder, colored the font in A red and
then deleted a row. I then turned off the macro recorder and looked at
the code. I also double-checked on the help system that you could
replace Columns("A:A") by Columns(1) (which looks slightly better in my
opinion - but you might want to leave it as Columns("A:A"). It's best
to know about both usages, since it might be a hassle to figure out the
column number of column BF for example)
In any event - a combination of the macro recorder and help (and
google) can clear up most questions about syntax. Just remember to
avoid all the selections that the macro recorder records and replact
them by direct references to the relevant objects.

HTH

-John Coleman
 

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

Top