+ Reply to Thread
Results 1 to 7 of 7

Macro to control Conditional Formatting

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Macro to control Conditional Formatting

    Hi all,

    I have a conditional format that I would like to run as a macro instead - really just so I can get a thick red line instead of a thin line as seams to be the only offering in the conditional formatting format window. [the macro puts a red cell border line on the top of a cell if the date is different to the one above]

    The macro I have got which is currently not working is as bellow. Can someone very kindly tell me how to change this so will work? Ideally it will not require hitting 'run' every time in order to update the conditional formatting on the sheet.

    Please Login or Register  to view this content.
    Thank you very much indeed.

    Oliver
    Last edited by jeffreybrown; 01-07-2017 at 11:08 AM. Reason: Please use code tags!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to control Conditional Formatting

    As you identify the thick border is not available in CF

    Have you considered setting all borders for any range in question to a thick border and then using CF to identify cells which should NOT have a border and using CF to turn them off.

    In essence the reverse of what you've attempted.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Macro to control Conditional Formatting

    Ha!

    Thank you Richard.

    No I had not thought of it that way round.

    That works perfectly and no macro required!

    Thanks very much indeed.


    Oliver

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Macro to control Conditional Formatting

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    HTH
    Regards, Jeff

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to control Conditional Formatting

    Quote Originally Posted by OLLY-7 View Post
    Ha!

    Thank you Richard.

    ...snipped

    Oliver
    My pleasure and thanks for the Rep.

  6. #6
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Macro to control Conditional Formatting

    Thank you Jeff.

    Will do.

    However I just realised that while I can reverse the conditional formatting to do what I want (I.e. make all top and bottom cell borders in the table thick red lines and then use conditional formatting to turn the top cell border line to a thin black line if cell above is the same (ie. dates are the same)....

    ...What is happening of course is that when I add rows (as will happen) in the middle of the table, the conditional formatting is getting split up leading to undesirable results.

    Also adding data rows at the bottom of the table does also not extend the formatting range.

    so still have an issue.

    Might a macro still be the answer?

    I would like this to be automated as can not rely on the user being an excel wiz and fixing the formatting range every time they add rows.


    I attach the worksheet which should show the issue.


    If someone has a solution I'll be most obliged.


    Oliver

  7. #7
    Registered User
    Join Date
    03-29-2013
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    78

    Re: Macro to control Conditional Formatting

    Might it be possible to have NO conditional formatting in the table, have all table top and bottom border lines as thin black lines and then use a macro with some kind of IF statement to format top borders with a thick red line if the cell above (in date column) is different... i.e.
    This all assumes / hopes that the range in the macro will grow when rows are added.

    So something like...

    IF: =$AN7<>$AN6

    Then do this for each cell in complaint row:

    With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .Color = -16776961
    .TintAndShade = 0
    .Weight = xlThick

    Do this formatting to this range: =$B$7:$BA$29


    (The above section of code is from a macro I recorder - so wondering if this can be incorporated into an IF function rather than trying to code conditional formatting which, as we know, does not allow the thick red line option (weird), but clearly thick red line formatting CAN be coded!



    Thank you again.

+ 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. Macro to set up conditional message based on results of conditional formatting
    By paysola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2016, 12:38 AM
  2. Macro For Conditional Formatting
    By S-Hart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2015, 05:52 PM
  3. Conditional Formatting and Spreadsheet Control?
    By threeaeabawys in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2014, 10:14 PM
  4. Control bubble chart colors with conditional formatting in Excel 2010
    By jschmidtfpi in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-29-2013, 11:06 AM
  5. Macro for Conditional Formatting
    By ajt1337 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-20-2013, 04:04 PM
  6. Macro for formatting fonts and cell colours - not Conditional Formatting
    By Kayaness in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-07-2011, 03:46 AM
  7. conditional formatting macro
    By JChandler22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2008, 08:51 AM

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