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
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

tlowry

Well-known Member
Joined
Nov 3, 2011
Messages
1,367
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,472
Messages
5,596,354
Members
414,060
Latest member
hermanseck

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
Top