Welcome to the forum, why do you need VBA for this? it is much easier with conditional formatting.
Either way to answer your question preferably we would like a screenshot (click on XL2BB in my signature block to see the preferred method for doing this), and definitely need to know what the range and the number are.
Sub HighlightCell()
Dim cell As Range, aNumber As Integer
aNumber = 5
Set cell = Selection
If Selection.Count > 1 Then Exit Sub
If Selection.Value > aNumber Then Selection.Interior.Color = vbYellow
End Sub
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.