Highlighting Cells

Najwan

New Member
Joined
Nov 12, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
VBA to highlight the cell if value is exceeding a certain number
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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.
 
Upvote 0
VBA Code:
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
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,518
Members
452,650
Latest member
Tinfish

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