+ Reply to Thread
Results 1 to 9 of 9

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

  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.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

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

    Please use code tags when posting. Maybe:

    Please Login or Register  to view this content.

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

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

    Perfect John, that works a treat !!!! Made my day

    Will be using code tags going forward...

    Have a nice weekend

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

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

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

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

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

    Actioned as per your note above. Thanks again for the quick response, enjoy your weekend

  6. #6
    Registered User
    Join Date
    03-15-2015
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

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

    Hi there, Just wondering what the text would be if you only wanted cells B, H & J coloured.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

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

    @ Fred33 -

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-15-2015
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

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

    Thanks John,
    I tried something similar,
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

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

    Yep. That should work also.

+ Reply to Thread

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