+ Reply to Thread
Results 1 to 8 of 8

script for conditional formatting

  1. #1
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    script for conditional formatting

    Hi,

    I tried recording my conditional formatting settings but for some reason it doesn´t write it down in the script.

    I would like the format to be:

    When a value in column O is bigger than 0, color the entire row red and text bold, for which has this value in range (A2:Lastcell).

    Does someone has a script like this?

    Thanks,
    Crispy

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: script for conditional formatting

    See the attached file..

    Try this - Select Data Excluding Headers > Alt+O > D > New Rule > Use Formula To Determine > =$O2>0 > Apply Formatting
    Attached Files Attached Files
    Cheers!
    Deep Dave

  3. #3
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Re: script for conditional formatting

    Hi Crispy,

    I was looking at doing conditional formatting in VBA, but the upshot was that it is much slower than the Excel conditional formatting, so if it is possible to set the CF on the sheet then that is definitely best.

    The only reason I could find for scripting CF is if you are adding a worksheet within your macro and you want it to automatically populate the CF. The only other reason is if you want to use more than 3 conditional formats in a cell, then you have to use VBA. Avoid if, like me, you are new to VBA, you will be adding research time to your efficiency.

    NeedForExcel's answer should solve your problem.

    Kind regards
    Rob

  4. #4
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: script for conditional formatting

    Hi both,

    Yes NeedForExcel, that's how i created the conditional formatting too. However, this requires a manual step that i'm trying to avoid.
    The Macro creates a new sheet every time where it needs to put this formatting. So it isn't a fixed template where i can pre-set conditional formatting.

    Is there then maybe a code that does color the row right and text bold whenever a value in O:O is >0?

    something like:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: script for conditional formatting

    Oh wait. My script actually worked... what the.

    Thanks guys!!!

  6. #6
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: script for conditional formatting

    But i want it to color the whole row.

    i tried something like this but it doesn't work

    [CODE][/Sub color()

    Dim myRange As Range
    Dim cell As Range
    Set myRange = Range("O2:O" & Rows.Count)
    For Each cell In myRange
    If cell.Value > 0 Then cell.EntireRow.cell.Font.ColorIndex = 5
    NextCODE]

    any ideas?

  7. #7
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: script for conditional formatting

    *Accidental double post because of server problems*
    Last edited by Crispy85; 07-02-2015 at 10:58 AM. Reason: *Accidental double post because of server problems*

  8. #8
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: script for conditional formatting

    Hi.
    Found the problem. Might as well be usefull for some other people in the future:

    Please Login or Register  to view this content.
    This macro gives the color blue (5) to all the rows, where in column O the value is bigger than 0.

+ 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. Need help with VBA script for conditional formatting
    By qwertybirdy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2014, 04:09 PM
  2. Opening xlsm files with conditional formatting opens with removed conditional formatting
    By Martijn.Steenbakker in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-07-2014, 05:38 AM
  3. [SOLVED] Script which allows user to define the color in conditional formatting
    By PariD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2012, 03:55 PM
  4. VB script to do conditional formatting of font size
    By Antila in forum Excel General
    Replies: 4
    Last Post: 06-20-2011, 01:50 PM
  5. VB Script Sorting and Conditional Formatting?
    By fasterthanyours in forum Excel General
    Replies: 12
    Last Post: 07-30-2009, 02:09 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