VBA Shortcut for Conditional Format Function

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
1,015
Office Version
  1. 365
Platform
  1. Windows
Hi all - I am curious to know if there is a way to create a button that will execute a shortcut to an existing function?

Conditional Formatting --> Highlight Cells Rules --> Text That Contains

I am using this function quite a bit and would love it, if there was a way to make this a "1-click" process

Any help or direction would be greatly appreciated!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I ran the macro recorder, then made a few edits :

VBA Code:
Option Explicit

Sub Macro1()
'
' Macro1 Macro
'

'
    Selection.FormatConditions.Add Type:=xlTextString, String:=xlCellValue, _
        TextOperator:=xlCellValue
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
End Sub
 
Upvote 0
I ran the macro recorder, then made a few edits :

VBA Code:
Option Explicit

Sub Macro1()
'
' Macro1 Macro
'

'
    Selection.FormatConditions.Add Type:=xlTextString, String:=xlCellValue, _
        TextOperator:=xlCellValue
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
End Sub
Keep in mind, as always, that executing any function with VBA eliminates UNDO Cntl-Z possibilities... even if just using VBA, since Excel appears to lacks a keyboard shortcut, to open the Conditional Format Manager... just say'n... :)
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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