Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-28-2008, 02:39 AM
Novice
 
Join Date: Jul 2008
Posts: 11
leroytrolley is on a distinguished road
Default Code for Changing Cell Backgrounds

Sorry about the trivial title but...



I need to be able to compare to figures in different cells, and if one is larger than the other fill the cell with a red background.

Something along the lines of

if cell a1 is greater than cell b1
then
make a1 red
else
make cell a1 green

I will need to copy the same formula in to other cells too.

Thank you.
Reply With Quote
  #2  
Old 12-05-2008, 02:03 AM
Novice
 
Join Date: Dec 2008
Posts: 1
et5323 is on a distinguished road
Default

Reference:
sub test()
dim rng as range
for each rng in range("a1:a5")
with rng
if .value>.offset(0,1).value then
.interior.colorindex = 3
else
.interior.colorindex = 4
end if
end with
next
end sub
Reply With Quote
  #3  
Old 12-05-2008, 02:05 AM
Novice
 
Join Date: Jul 2008
Posts: 11
leroytrolley is on a distinguished road
Default

Thanks, but I found the "Conditional Formating" options did exactly what I needed.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop down box in a cell Grapejuice Excel 0 10-22-2007 07:40 PM
Changing DataSource ntfirewall Mail Merge 0 03-30-2007 06:01 AM
IRR with Changing Signs aml480 Excel 0 03-16-2006 11:27 PM
FileSaveAs with Code bsmith Office 0 01-05-2006 08:43 AM
Question concerning Backgrounds and fading. NYCorBUST PowerPoint 2 12-29-2005 09:05 AM


All times are GMT -7. The time now is 11:56 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft