highlight minus values in specific column

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
397
Office Version
  1. 2016
Platform
  1. Windows
Hi

I got this code for Rick Rothstein and I modified to fit with my requiremnt but I failed . so what I want any minus values in column E should be red font values and if the minus values return to positive then should return the color to black .
VBA Code:
Sub minusvalues()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "E").End(xlUp).Row
  Range("E2:E" & LastRow) = Evaluate("IF(E2:E" & LastRow & "<0,RGB(255, 0, 0),E2:E" & LastRow & ")")
End Sub
thanks

 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
did you want VBA, it can be done just with conditional formatting
 
Upvote 0
just question . if CF deal with changes, then should return the color to black again . I mean if I have red minus value and if change to positive , then should be black . if so i don't mind with CF
 
Upvote 0
if black is the default colour the allyou are doing is changing to red for <0

but i maybe miss reading

Book2
A
22
31
4-1
5-2
61
72
81
9-1
10-2
111
122
133
14-1
15-2
161
172
183
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A18Expression=A2<0textNO
 
Upvote 0
unfortunately it doesn't work to see if it's what I want. It just highlight the first cell is positive despite of I select the whole range when implementation CF.:unsure:
 
Upvote 0
unfortunately it doesn't work to see if it's what I want. It just highlight the first cell is positive despite of I select the whole range when implementation CF.
If you selected the whole column (and it is column E like your code) then the conditional formatting expression would need to be =E1<0

However, you don't even need conditional formatting which is volatile as you can use a Custom Format

Try this after removing any conditional formatting in the column

Select the column and apply this format (you can see the results in column E at the left of the image)

1658545113923.png
 
Upvote 0
Solution
You're welcome. Thanks for the follow-up.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top