Link to home
Create AccountLog in
Avatar of leezac
leezac

asked on

Cell color

I need to be able to highlight a cell if it contains a hyphen or dash "-".  This is what I have, but does not work. Thanks in advance!

Sheets("View").Activate
 
   Range(Range("I1"), Range("I1").End(xlDown)).Select
   For Each cell In Selection
      If cell = "-" Then cell.EntireRow.Interior.ColorIndex = 4
   Next cell
SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Just realised you wanted the whole row coloured, so slight change.

Select the whole area and the CF formula would then be:

=FIND("-",$I1,1)>0

Only change being the addition of the $ in front of I to ensure that CF in all columns are looking at Column I.

Thanks
Rob H
Avatar of leezac
leezac

ASKER

No nothing works.  I entered the hypen manually to test but it is entered via a macro if the cell is null.  I tried conditional formating but it is deleted somehow when the file is updated.
Can you attach your workbook and describe the steps to take to reproduce the problem?
Avatar of leezac

ASKER

I also do not want row colored - just cell
Can you attach your workbook and describe the steps to take to reproduce the problem?
Avatar of leezac

ASKER

Decided to use a "0' instead of '-" and it works now with conditional formatting.