Ignoring zeros in macro

PedroMojica

New Member
Joined
Jul 19, 2011
Messages
9
having trouble typing code to ignore the zeros in the spreadsheet, just trying to bold the lowest number without it being zero. Here is the code I have right now, cant seem to find the right combination to not count the zeros in each column.

Sub BoldMinimum()
Selection.FormatConditions.Delete
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=" & ActiveCell.Address(0, 0) & _
"=Min(" & Selection.Address & ")"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
End With
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What is the range of cells in which you are trying to determine the lowest value (other than 0 of course)? Or is it going to be a different range that you will select each time?
 
Upvote 0
This will apply the conditional formatting to all 5 columns simultaneously: C-G

Code:
Sub CondFormat()

Range("C28:G32").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND(C28>0,C28=MIN(IF(C$28:C$32>0,C$28:C$32)))"
End Sub
 
Upvote 0
Code:
Sub CondFormat()

Range("C28:G32").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND(C28>0,C28=MIN(IF(C$28:C$32>0,C$28:C$32)))"
    With Selection.FormatConditions(1).Font
        .Bold = True
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,700
Members
452,938
Latest member
babeneker

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