How to Color cell in one row if cellvalue is higher or lower than specific number?

Stout

New Member
Joined
Jun 1, 2015
Messages
8
as the title said i want to know how to use a macro to Color a cell in one row if the cell value is higher or lower than specific number.

for the moment i have this

Dim myLastRow As Long
myLastRow = Range("D65536").End(xlUp).Row
Range("B" & myLastRow + 1).Resize.FormulaR1C1 = "=COUNTIF(R[" & -myLastRow & "]C:R[-1]C,""<1"")"


Range("D" & myLastRow + 1).Resize(, 42).FormulaR1C1 = "=COUNTIF(R[" & -myLastRow & "]C:R[-1]C,"">4"")"


Range("AT" & myLastRow + 1).Resize(, 76).FormulaR1C1 = "=COUNTIF(R[" & -myLastRow & "]C:R[-1]C,"">5"")"

i want the cell to become red if its go higher than zero and if it stays at zero i want it to become green.
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

svendiamond

Well-known Member
Joined
Jun 13, 2014
Messages
1,498
Office Version
  1. 365
Platform
  1. Windows
I'm not sure about how to edit your macro but why not just use conditional formatting? Have you already explored that option?
 

Stout

New Member
Joined
Jun 1, 2015
Messages
8
that would probably work but as i have to use this macro every day, it would take time to do that from other things i could be working on.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,337
Messages
5,601,026
Members
414,422
Latest member
acegreen

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
Top