In this tutorial, we are going to look at how to highlight the largest value in the selected range with Macros in Excel. VBA & Macros will make this work as simple as possible. Because we are going to do this with a few clicks. Let’s see the clear-cut instructions to highlight the max value in Selection using Macros in Excel Office 365.
Highlight Max Value in the Selection:
To select or highlight the largest value in the range, do as follows.
- In the below image, you can see the set of input values in the range B1:B10. We are going to find and highlight the largest value from this range.
- On the Developer Tab, select the Visual Basic option under the Code section.
- Then you need to copy and paste the code given below.
VBA code to highlight max value using Macros
Sub HighlightMaxVal()
Dim cell As Range
For Each cell In Selection
If cell = WorksheetFunction.Max(Selection) Then
cell.Style = “Note”
End If
Next cell
End Sub
- You need to save the code by selecting it. Then close the window.
- You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.
- You need to make sure that your macro is selected and click the Run button.
- At last, you will get the result as shown in the below screenshot.
Summary:
In this tutorial, we have demonstrated the clear-cut instructions to highlight the max value in Selection using Macros in Excel Office 365. Leave your feedback in the below comment section. Thanks for visiting Geek Excel. Keep Learning!
Top comments (0)