+ Reply to Thread
Results 1 to 5 of 5

Range: changing interior color

Hybrid View

Guest Range: changing interior color 11-10-2005, 11:25 PM
Guest Re: Range: changing interior... 11-10-2005, 11:40 PM
Leith Ross Hello Jim, Change your... 11-11-2005, 12:03 AM
Guest RE: Range: changing interior... 11-10-2005, 11:55 PM
Guest Re: Range: changing interior... 11-11-2005, 12:10 AM
  1. #1
    Jim Brass
    Guest

    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. #2
    Norman Jones
    Guest

    Re: 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: =$F11>0
    Select a pattern color
    OK


    ---
    Regards,
    Norman



    "Jim Brass" <jbrass@cfu.net> wrote in message
    news:dl12r7$6lh$1@news.cfu.net...
    >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. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Jim,

    Change your line of code to...

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

    Sincerely,
    Leith Ross

  4. #4
    Jason Clement
    Guest

    RE: 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
    >
    >
    >


  5. #5
    Ken Puls
    Guest

    Re: 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" <jbrass@cfu.net> wrote in message
    news:dl12r7$6lh$1@news.cfu.net...
    >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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1