DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

Highlight Min Value in Selection Using Macros in Excel Office 365!!

In this brief article, you will learn the simple steps to highlight min value in the selection using Macros in Excel Office 365. VBA & Macros plays a vital role in Excel. Because it is used for completing any kind of task with a few clicks. You just follow the steps given below to achieve the task.

Highlight Min Value in Selection Using Macros:

Follow the below instructions to highlight the smallest value in the range in Excel.

  • In the following image, you can see the set values in a range from B1:B10. We are going to find the smallest one from this input range.

Example
Example

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select the Visual Basic option

  • Then you need to copy and paste the code given below.

VBA code to highlight min value using Macros

Sub HighlightMinValue()

Dim cell As Range

For Each cell In Selection

If cell = WorksheetFunction.Min(Selection) Then

cell.Style = “Note”

End If

Next cell

End Sub

  • You need to save the code by selecting it. Then close the window.

Save the code
Save the code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Click the Run button
Click the Run button

  • At last, you will get the result as shown in the below screenshot.

Output
Output

Sum-Up:

To be crisp, you can understand the simple steps to highlight min value in the selection using Macros in Excel Office 365. Drop your feedback in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Also Read:

Top comments (0)