+ Reply to Thread
Results 1 to 4 of 4

VBA Code for Highlighting Cells based on If then Rules

  1. #1
    Registered User
    Join Date
    11-19-2022
    Location
    USA
    MS-Off Ver
    365
    Posts
    2

    VBA Code for Highlighting Cells based on If then Rules

    Hi, Attached is the excel data file for which I need to create a visual basic code with the following rules.
    1. If AssetCondition=Good and ReviseRul=0 and RULCalculated<=10, highlight all 3 cells.
    2. If AssetCondition=Good and ReviseRul=1 and RULOverride<=10, highlight all 3 cells.
    3. If Priority=Priority 1 and Level 5 does not include any of the following words=UPS, Emergency, Fire, Annunciation, Generator, Sprinkler, highlight both cells.
    4. If RULCalculated!=YearinService+EUL-Current Year, highlight all 3 cells.
    5. IfUnitCost field is blank, then highlight that cell.
    6. If Manufacturer field is blank, then input "Not Visible" in cell
    7. If CapacityUnitOfMeasure=numeric value, highlight cell.
    8. Update all cells in PlanType column as capital letters.
    9. If YearManufactured contains comma then highlight cell.


    Can someone please help me write this rule. Thanks in advance
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: VBA Code for Highlighting Cells based on If then Rules

    try

    edited some values to test rules

    i think someone can think of a better code in lines of code in '3 :D

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-19-2022
    Location
    USA
    MS-Off Ver
    365
    Posts
    2

    Re: VBA Code for Highlighting Cells based on If then Rules

    Thank you soo much, I will try this out. The rules I posted below are sample, I have about 50 such rules, would you know if I can continue coding the remaining 40 similar to how you have done for the below 9 or is there a max limit?

  4. #4
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: VBA Code for Highlighting Cells based on If then Rules

    im not sure about 50 rules in a single sub is not ideal
    maybe breakdown each rule in each sub maybe

+ 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. excel help calander (highlighting/rules) need new formula
    By crashins in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-28-2017, 11:18 PM
  2. Code/Rules for pulling cells between tabs
    By cuttothechase in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2017, 10:56 AM
  3. Help With Creating a VBA code based on 4 rules
    By anfdrew in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2014, 08:26 PM
  4. Excel VBA code to sort table and move cells around according to set rules
    By abdul4me in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2013, 07:18 AM
  5. Need a vba code to check the status and based on rules calculate service years
    By baba_excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-19-2012, 09:03 PM
  6. Sum cells based on 2 variable rules
    By GenericPat in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-23-2012, 09:56 AM
  7. Replies: 2
    Last Post: 10-08-2008, 04:35 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