create a button to do conditional formatting

kerm007

Active Member
Joined
Mar 16, 2019
Messages
250
Office Version
  1. 365
Platform
  1. Windows
hello
i try to do a conditional formating with a button
i have this code but its not right

VBA Code:
ub Highlight()
Dim MyRange As Range
'Create range object
Set MyRange = Sheets("Fixtures").Range("B:D")
'Delete previous conditional formats
MyRange.FormatConditions.Delete
'Add first rule
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="=H", Formula2:="=150"
MyRange.FormatConditions(1).Interior.Color = RGB(255, 0, 0)
End Sub

i have number on colum B and F and some are Numbers with an H
i want to put in bold and red the line where its number and H
like 60H

can i do that ?
Thanks

ps: the button i create is on another sheet because when i ran the fixture the button disapear
ty
 

Attachments

  • Capture.PNG
    Capture.PNG
    15.4 KB · Views: 17
Last edited:
hi again
i was able to run conditinal formating on the page but this rule was not kept after i ran another script
can we add this to the previous code and when i press the button it will do all ?
Thankks
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
who can help me to add another formatting when it see the no game either on the B and F colum i know how to get it yellow but everything i try its not doing anything i miss something for sure :)
 
Upvote 0
hello this what i did so far


Sub Bye()

Dim MyRange As Range
Dim FormulaStr As String

'Create range object
Set MyRange = Sheets("Fixtures").Range("B:F")

'Delete previous conditional formats
MyRange.FormatConditions.Delete

'Create Formula
'=AND(RIGHT(B1,1)="No Game"
FormulaStr = "=AND(RIGHT($B1,1)="

'Add first rule
With MyRange.FormatConditions.Add(xlExpression, Formula1:=FormulaStr)
.Interior.Color = RGB(255, 255, 0)
.Font.Bold = True
.Font.Color = vbWhite
End With

End Sub


not working :(
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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