Select the entire row

S

shantanu oak

I want to select the entire row and change the color of the row where
the word "CASH" is in a single cell.

The following code of the macro is not working.

'
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue,
Operator:=xlEqual, _
Formula1:="=""CASH"""
Rows(FormatConditions(1)).Select
Selection.Font.ColorIndex = 45


Please guide.
 
B

Bob Phillips

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="CASH"
Selection.FormatConditions(1).Font.ColorIndex = 345


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
S

shantanu oak

Hi,
I want to highlight the entire row in which the word cash appears.

Shantanu
 
B

Bob Phillips

With Selection.EntireRow
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=" & ActiveCell.Address(False,
True) & "=""CASH"""
.FormatConditions(1).Font.ColorIndex = 45
End With



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
S

shantanu oak

Thanks.
Now I want to color alternate rows using conditional formatting and I
can do it manually by using this formulae...
=ODD(ROW())=ROW()

How do I add it in a macro?
 
B

Bob Phillips

With Selection.EntireRow
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=ODD(ROW())=ROW()"
.FormatConditions(1).Font.ColorIndex = 45
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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