How can I modify the color of a cell?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am an Excel beginner, but learning a lot from the experts in this newsgroup. My problem is simple - I have two cells that I am monitoring. If cell 2 is larger in value than cell 1 (a1 < a2), then I need to "highlight" the the cell next to them in Red. If the A1 < A2 condition exists, I call a UserForm and will change the background color of that 3rd cell via an offset in the Userform. What I don't know how to do is change the background color. I would appreciate any help that can be offered. Thank you

JP
 
James,

Not sure how you will call the userform when A2>A1, but to set a cell's
colour, just use

Range("A3").Interior.ColorIndex = 8

To see all of the standard colours, look up 'Colorindex Property' in VBA
Help.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

James Prontier said:
I am an Excel beginner, but learning a lot from the experts in this
newsgroup. My problem is simple - I have two cells that I am monitoring. If
cell 2 is larger in value than cell 1 (a1 < a2), then I need to "highlight"
the the cell next to them in Red. If the A1 < A2 condition exists, I call a
UserForm and will change the background color of that 3rd cell via an offset
in the Userform. What I don't know how to do is change the background color.
I would appreciate any help that can be offered. Thank you.
 
Possibly this is what you are looking for.

Range("A1").Select
With Selection.Interior
..ColorIndex = 3
..Pattern = xlSolid
End With
 
You might also want to check out Conditional Formatting for that part as opposed
to VBA. Might be a better option.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



James Prontier said:
I am an Excel beginner, but learning a lot from the experts in this newsgroup.
My problem is simple - I have two cells that I am monitoring. If cell 2 is
larger in value than cell 1 (a1 < a2), then I need to "highlight" the the cell
next to them in Red. If the A1 < A2 condition exists, I call a UserForm and will
change the background color of that 3rd cell via an offset in the Userform. What
I don't know how to do is change the background color. I would appreciate any
help that can be offered. Thank you.
 
Back
Top