Results 1 to 9 of 9

VBA Conditional Format Range of cells based upon criteria in one cell. Repeat for all rows

Threaded View

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    VBA Conditional Format Range of cells based upon criteria in one cell. Repeat for all rows

    Scratching my head and have visited few forums but unable to find the resoltion. Hoping I can pick your brains and help me resolve this mystery !!

    Code is trying to
    1. Where there is data in column B
    2. Goto first row of data
    2. If column J = "Closed"
    3. then select Cells from column B to J in that row and colour these cells in red
    4. If column J= "Open"
    5. the select Celss from column B to J in that row and colour these cells in grey
    4. Repeat for next row until you get to cell in column B where there is no data.

    Recieve run time error 1004: Method 'RAnge of object_GLobal failed

    ===============================================================
    Sub Colourclosed()

    Sheets("Risks").Select
    Dim LastRow As Long
    Dim i As Long
    LastRow = Range("B" & Rows.Count).End(xlUp).Row
    For i = 8 To LastRow

    If Range("J" & i).Value = "Closed" Then Range("B", "J" & i).Select
    Selection.Interior.ColorIndex = 3


    If Range("J" & i).Value = "Open" Then Range("B", &"J" i).Select
    Selection.Interior.ColorIndex = 15

    Next

    End Sub

    ======================================================

    Your help much appreciated

    Note: I've managed to do it for one cell ie for Column B by replacing "If Range("J" & i).Value = "Closed" Then Range("B", "J" & i).Select
    with "If Range("J" & i).Value = "Closed" Then Range("B" & i).Select" This works but only colours in cell in column B, how do i do this so it colours range of cells
    Last edited by razwan1978; 04-04-2014 at 04:08 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 10-24-2013, 05:34 PM
  2. Replies: 3
    Last Post: 09-13-2012, 03:25 AM
  3. [SOLVED] Conditional Format column based on value of a range of cells.
    By pauld.ccvw in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-27-2012, 09:35 AM
  4. [SOLVED] Conditional Format cell based on value of cells in range
    By Dean81 in forum Excel General
    Replies: 5
    Last Post: 03-20-2012, 12:20 PM
  5. Replies: 4
    Last Post: 12-17-2011, 06:11 PM

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