Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Range: changing interior color

I have a spreadsheet that has info in columns A thru F. I am trying to write
a macro that will background color the row if the cell in column F is
greater than Zero. In other words if in row 11 cell F11 is 5, I want cells A
thru F of row 11 to be colored green. I have tried

If F11 0 then Range("A11:F11").InteriorColor = 4

but it doesn't work. What should I do? By the way, I want this to work for
values in rows 11-22. Thanks Jim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Range: changing interior color

Hi Jim,

This can be achieved with conditional formatting.

Select the range to highlight, say A11:Z22
Format | Conditional Formatting
Formula is: =$F110
Select a pattern color
OK


---
Regards,
Norman



"Jim Brass" wrote in message
...
I have a spreadsheet that has info in columns A thru F. I am trying to
write a macro that will background color the row if the cell in column F is
greater than Zero. In other words if in row 11 cell F11 is 5, I want cells
A thru F of row 11 to be colored green. I have tried

If F11 0 then Range("A11:F11").InteriorColor = 4

but it doesn't work. What should I do? By the way, I want this to work for
values in rows 11-22. Thanks Jim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Range: changing interior color

You can do this without a macro using conditional formatting:

Select all the cells that the fomatting will apply to (hold and drag
starting from the top row).
Click Edit-Conditional Formatting
Change the dropdown from "Cell Value Is" to "Formula Is" and type "=$F11
0" in the textbox
Click the format button and make the background green.
Hit OK then OK again and that's it.


Within a macro (if you have to have it):

Sub SetRangeColor()
For i = 11 to 22
if Range("F" & i).Value 0 Then Range("A" & i & ":F" &
i).Interior.Color = vbGreen
Next
End Sub



"Jim Brass" wrote:

I have a spreadsheet that has info in columns A thru F. I am trying to write
a macro that will background color the row if the cell in column F is
greater than Zero. In other words if in row 11 cell F11 is 5, I want cells A
thru F of row 11 to be colored green. I have tried

If F11 0 then Range("A11:F11").InteriorColor = 4

but it doesn't work. What should I do? By the way, I want this to work for
values in rows 11-22. Thanks Jim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range: changing interior color


Hello Jim,

Change your line of code to...

If F11 0 then Range("A11", "F11").Interior.Color = 4

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48417

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Range: changing interior color

I agree with the other responses that you should do this with conditional
formats.

For reference, you're macro would work if you changed it to:

If Range("F11").Value 0 then Range("A11:F11").InteriorColor = 4

Cheers,

--
Ken Puls
www.officearticles.com


"Jim Brass" wrote in message
...
I have a spreadsheet that has info in columns A thru F. I am trying to
write a macro that will background color the row if the cell in column F is
greater than Zero. In other words if in row 11 cell F11 is 5, I want cells
A thru F of row 11 to be colored green. I have tried

If F11 0 then Range("A11:F11").InteriorColor = 4

but it doesn't work. What should I do? By the way, I want this to work for
values in rows 11-22. Thanks Jim



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
color the interior of a range Pierre via OfficeKB.com Excel Worksheet Functions 1 November 2nd 05 12:55 PM
Events... Changing the Interior Color kraljb[_5_] Excel Programming 2 July 17th 05 06:58 PM
Passing Back Color to Interior Color ExcelMonkey[_190_] Excel Programming 1 March 22nd 05 04:27 PM
Find range by interior color CG Rosén Excel Programming 3 December 10th 03 01:12 AM
Interior Cell color Pellechi Excel Programming 1 September 23rd 03 03:39 PM


All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"