Excel Macro for Coloring the cells

  • Thread starter Thread starter Dhawal
  • Start date Start date
D

Dhawal

Hello,

I have a worksheet in which I have the data arranged ap per the
temperature.
There are 3 temperatures and for each temperature I have to put in a
color for all the cells.
The data is random and there is a set of data.
Can I get help doing that.

Dhawal
 
Check out Conditional Formatting under Format.

Options for Greater than, Less than, Equal to, etc.

HTH
Regards,
Howard
 
You can call this in either a function or a subroutine...

In either case here a an example of a subroutine that will work (wrote
it really quick so pardon the lack of eloquence)

You can change around the variables however you see fit - Enjoy!

----------------------------------------------------------------------------

Option Explicit

Sub tempCalc()
Const startRow = 1
Const startCol = 1
Const endRow = 1
Const endCol = 3
Dim rRng As Range
Dim cCell As Object
Set rRng = Range(Cells(startRow, startCol), Cells(endRow, endCol))
For Each cCell In rRng
Select Case cCell.Value
Case Is <= 32
cCell.Interior.ColorIndex = 6
Case Is <= 60
cCell.Interior.ColorIndex = 4
Case Is > 60
cCell.Interior.ColorIndex = 8
End Select
Next cCell
End Sub
 

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

Back
Top