Change the Conditional Format Color of a Text Field Using a Button

CJBills

New Member
Joined
Apr 27, 2015
Messages
13
On a form, a text field has the three color conditions allowed in the Conditional Formatting dialog box.

OBJECTIVE:
I need a button to change the color of the text field from one of the three to a new color condition (grey).

RESEARCH:
In my research I have found a delete condition (I believe: Me![txtFieldName].FormatConditions.Delete), which hasn't worked, and a I'm not sure if deleting conditions is necessary. A lot of coding I've found includes If/Then statements, which do not seem to apply (except for If [you press this button] Then [that field will change from whatever color it is to Grey].

Any suggestions would be gratefully appreciated.
Thanks, in advance.
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Maybe this:

In your button "Click" event:
Code:
Dim oFormat As FormatCondition

On Error Resume Next
   For Each oFormat In ActiveCell.FormatConditions
        oFormat.Interior.ColorIndex = 15
   Next oFormat
On Error GoTo 0
 
Upvote 0
Thanks, Gary McMaster. I was not able to get it to work. Although it led me to the following solution.

SOLUTION:
Code:
Private Sub GreyTextField_Button_Click()
    
    Text1.BackColor = RGB(191, 191, 191)

End Sub

Thanks, again!!!!
This is getting awesome.
 
Upvote 0
Although it led me to the following solution.

OK, I'd say I couldn't have misinterpreted your question any more completely but it's good to hear you got it working. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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