VBA alternative to conditional formatting

LORDMARKS

New Member
Joined
Jun 5, 2014
Messages
39
Hi all. I am working on a large data entry and reporting system in excel. Currently the area of drop down boxes covers 1.3 million cells and will probably end up double that. I was using excels inbuilt conditional formatting to grey out box's that are contain an "X" to improve the user interface, however this seems to greatly slow down the autofilters.

I have tried using the find replace function within VBA, as I am using it anyway, to replace the formatting aswell, but it doesnt seem to do anything?

What I am after is the most efficient way to look at a large range and apply 'Grey Background' formatting if the cell contains "X"


Thanks as always
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
What I am after is the most efficient way to look at a large range and apply 'Grey Background' formatting if the cell contains "X"

I'm not clear on exactly what you want, so I did the simplest approach:
Code:
Sub test()
    With Worksheets("Sheet1").UsedRange
        .Replace What:="X", Replacement:="#N/A", _
                SearchOrder:=xlByColumns, MatchCase:=True
        .Cells.SpecialCells(xlConstants, xlErrors).Interior.ColorIndex = 15
        .Replace What:="#N/A", Replacement:="X", _
                SearchOrder:=xlByColumns, MatchCase:=True
    End With
End Sub

The above code will "grey" all cells that have a single, capital "X" and will go as fast as I know how to make it.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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