Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2008, 02:39 AM
leroytrolley leroytrolley is offline
Novice
Code for Changing Cell Backgrounds
 
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
et5323 et5323 is offline
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
leroytrolley leroytrolley is offline
Novice
Code for Changing Cell Backgrounds
 
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
Code for Changing Cell Backgrounds Question concerning Backgrounds and fading. NYCorBUST PowerPoint 2 12-29-2005 09:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft