VBA Code for Highlighting Cells based on If then Rules

Status
Not open for further replies.

ShwetaD

New Member
Joined
Nov 18, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
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.
Sample Data File.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBH
1AssetIDClientNameAgencyCampusBuildingLevel1Level2Level3Level4Level5GuidCSICodeUnitCostUnitofMeasureDeficiencyClassREFNumberAssetConditionPlanTypePriorityQuantityYearinServiceAssetLocationMoreSpecificLocationCapacityCapacityUnitOfMeasureManufacturerModelNumberBarcodeNumberAssetTagSerialNumberAssetLabelAgeIsIncludeReplaceInPlanItemAssessmentYearInterventionStatusWarrantyYearManufacturedDescriptionConditionConditionRatingNotesHasImagesReviseRULRULCalculatedRULOverrideUnadjustedTotalCostEULAnnualSavingsSimplePaybackYearsUnitCostSavingsParentAssetIDClientIDAgencyIDCampusIDBuildingIDClientGUIDAgencyGUIDCampusGUIDBuildingGUIDIsActionItemDateAssessed
21LauN/A0079bBg1A SubStructureA10 FoundationsA1000 FoundationsA1000 FoundationsA100001 Engineering Study of Foundation5000EACHScheduled ActionPlan Type 1 - Deferred MaintenancePriority 2 - Currently Critical12023Engineering Study of Foundation1005000600UOL-ULB-DURBLDG-0079JM-B201128-41
32LauN/A0079bBg3B ShellB20 Exterior EnclosureB2030 Exterior DoorsB2032 Solid Exterior DoorsB203203 Paint Exterior Doors2.7405SFScheduled ActionPlan Type 1 - Deferred MaintenancePriority 3 - Necessary / Not Critical52023Refinish Glazed Exterior Doors1001644.3300UOL-ULB-NATURALSCIENCE-0034PH-B203100-71
43LauN/A0079bBg1B ShellB20 Exterior EnclosureB2030 Exterior DoorsB2032 Solid Exterior DoorsB203203 Paint Exterior Doors2.7405SFScheduled ActionPlan Type 2 - Routine MaintenancePriority 3 - Necessary / Not Critical12023Paint Exterior Doors100230.202300UOL-ULB-NATURALSCIENCE-0034PH-C102103-91
54LauN/A0079bBg1B ShellB20 Exterior EnclosureB2030 Exterior DoorsB2032 Solid Exterior DoorsB203203 Paint Exterior Doors2.7405SFScheduled ActionPlan Type 2 - Routine MaintenancePriority 3 - Necessary / Not Critical202023Refinish Interior Doors10024861.816300UOL-ULB-NATURALSCIENCE-0034PH-C102105-141
65LauN/A0079bBg1B ShellB20 Exterior EnclosureB2030 Exterior DoorsB2039 Other Doors and EntrancesB203909 Paint Exterior Doors2.7405SFScheduled ActionPlan Type 2 - Routine MaintenancePriority 3 - Necessary / Not Critical52023Paint Exterior Doors100575.505500UOL-ULB-NATURALSCIENCE-0034PH-C102109-81
Sheet1


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

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Can I ask, why aren't you using conditional formatting for this?
 
Upvote 0
2 reasons
1. The above rules posted are only a sample, the overall set of rules about 50 rules and not all include highlighting eg. please see item 6 and 8.
2. Conditional formatting with soo many rules and 8000 rows data would make the file slow.

But I could be wrong and more than happy for you to advise how this can be achieved using conditional formatting. Please let me know.
 
Last edited:
Upvote 0

  1. Today, 11:20 PM#3
    SKD7
    SKD7 is online now

    VBAX Newbie
    reputation_pos.png
    JoinedNov 2022Posts2Location
    United%20States%203D.gif

    Arizona%203D.gif
Not sure if you intended to post this ...
 
Upvote 0
This is what I intended to reply

2 reasons
1. The above rules posted are only a sample, the overall set of rules about 50 rules and not all include highlighting eg. please see item 6 and 8.
2. Conditional formatting with soo many rules and 8000 rows data would make the file slow.

But I could be wrong and more than happy for you to advise how this can be achieved using conditional formatting. Please let me know.
 
Upvote 0
Hmm. I see that you posted here yesterday on a different but related (?) topic. I see also that conditional formatting was suggested there too. Let me read it and see why they didn't follow through with that.
 
Upvote 0
You've asked the same question at a different forum.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,584
Messages
6,125,673
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top