VBA conditional formatting: Cell contains a blank value

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I have a VBA code that clears conditional formats and then enters them back in for when fellow employees jumble them up so to speak.

The only conditional format I have issues with is the one that states: Cell contains a blank value. I do not know how to write this in VBA

Here is what I want:

1676393260979.png


and here is what I get (which does not work):

1676393321355.png


I do not know how to write the code for Cell contains a blank value.

VBA Code:
   With ThisWorkbook.Worksheets("2023")

With .Range("D3:D11010,F3:F11010").FormatConditions
.Add xlExpression, Formula1:="=LEN(TRIM(A2))=0"
.Item(.Count).Interior.PatternColorIndex = xlAutomatic
.Item(.Count).Interior.ThemeColor = xlThemeColorAccent4
.Item(.Count).Interior.TintAndShade = 0.399945066682943
.Item(.Count).StopIfTrue = False
End With

Help with this would be greatly appreciated! :)
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Your formula should refer to row 3 not row 2. Personally I would use:

VBA Code:
.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="="""""
 
Upvote 1
Solution
Your formula should refer to row 3 not row 2. Personally I would use:

VBA Code:
.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="="""""

Thank you so much! Works Perfectly!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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