+ Reply to Thread
Results 1 to 5 of 5

Conditional Formatting, VBA

  1. #1
    Registered User
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    94

    Conditional Formatting, VBA

    Very new to VBA here so want to know what the code structure looks like to set conditional formatting to a column when criteria is met. So if values in D1 is non-blank then want to set formatting conditions to cells in column D. I am not familiar with "if" statement so don't know how to create it. thanks

    I don't want to use conditional formatting

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Conditional Formatting, VBA

    Quote Originally Posted by KerahJoy View Post
    ...set conditional formatting...I don't want to use conditional formatting
    This seems contradictory. It's not clear what you want the code to do.

    1. Use VBA to create Conditional Formatting rules
    2. Use VBA to directly format the cells

    Please be more specific about your data and the desired formatting. "set formatting conditions to cells in column D" Which cells? What formatting?

    I can show you a solution that does not use conditional formatting, but using built-in features is better than writing code to do the same thing.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    94

    Re: Conditional Formatting, VBA

    My data comes from a query which gets updated via refresh. The data lays out horizontally. As more data is added, additional columns get added to the right of the table. Formatting rules only duplicate vertically in a table as more rows get added....not horizontally when new columns are added. Therefore I'm hoping for a macro to do the trick. So to answer your question......I need VBA to create Conditional Formatting rules...but to apply after the refresh occurs.

    See attached: Column D is current data. Columns E thru G is new data which I want formatted as column D. So if new cell in row 1 is NOT empty, formatting rules should apply to that entire new column.
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Conditional Formatting, VBA

    How are new columns added? You have no code in this file even though it is a .xslm file, so I don't know if you do this manually, by import, or by code that is not included.

    My suggestion is going to be to set up the conditional formatting in D has you have done, then when new columns are added, use VBA to copy & paste formats. That will be much easier and more reliable than writing all of the conditional formatting logic in VBA.

    Also you do have a handful of conditional formatting rules that affect a couple of rows, but in looking at your sample I suspect you want other formatting too. Can you give a complete set of requirements for your desired formatting?
    Attached Images Attached Images
    Last edited by 6StringJazzer; 03-18-2022 at 10:54 AM.

  5. #5
    Registered User
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    94

    Re: Conditional Formatting, VBA

    They are added when query refreshes.......data is laid out horizontally.

    So what is a macro to duplicate formatting rules from column D and into E, F, G........ONLY when new data is added to those new columns?

+ 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. [SOLVED] Conditional Formatting based on another cells Conditional Formatting
    By chriskay in forum Excel General
    Replies: 4
    Last Post: 08-22-2019, 05:33 AM
  2. [SOLVED] Override conditional formatting (in general, without changing the conditional formatting)
    By Stormin' in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-21-2017, 07:15 AM
  3. Conditional Formatting Removing Previous Conditional Formatting?
    By CravingGod in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2016, 01:02 PM
  4. Replies: 6
    Last Post: 01-08-2016, 06:44 PM
  5. 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
  6. Replies: 1
    Last Post: 09-20-2013, 06:23 PM
  7. Replies: 3
    Last Post: 05-15-2012, 04:13 PM

Tags for this Thread

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