Results 1 to 8 of 8

Thread: Highlight minimum value ignoring 0

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Highlight minimum value ignoring 0

    Hi all,

    I have an excel to compare the prices given by suppliers. Each column is to compare the prices submitted by the suppliers for the item that they were asked to quote which consists of item price, mold price, total price with mold=item price+(mold price/quantity).


    I would like to:
    highlight the minimum value for total price with mold, that is higher than 0 and also ignoring blank.
    loop through the each column until there is no more items in row 2.

    I managed to find the following code while googling that partially fit my need, but the problem is that it keeps highlighting 0 or blank value.

    I have attached the intended result that I should see.

    Option Explicit

    Sub lowest()
    
        Dim lowestAs Double ' Long for whole numbers.
        Dim rng As Range
        Dim cell As Range
    
        With Worksheets("Sheet1")
            Set rng = .Range("b5,b8,b11,b14,b17,b20")
            lowest= Application.WorksheetFunction.Min(rng)
            Debug.Print worstcase
    
            For Each cell In rng
                If cell.Value = lowest Then
                    cell.Interior.Color = rgbYellow ' Hightlight only cell.
                End If
            Next
    
        End With
    
    End Sub

    Thank you
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •