create a button to do conditional formatting

kerm007

Board Regular
Joined
Mar 16, 2019
Messages
67
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: 6
Last edited:

kerm007

Board Regular
Joined
Mar 16, 2019
Messages
67
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

kerm007

Board Regular
Joined
Mar 16, 2019
Messages
67
Office Version
  1. 365
Platform
  1. Windows
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 :)
 

kerm007

Board Regular
Joined
Mar 16, 2019
Messages
67
Office Version
  1. 365
Platform
  1. Windows
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 :(
 

Forum statistics

Threads
1,148,176
Messages
5,745,191
Members
423,931
Latest member
thangvan114

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