Set smallest cell in row,col as BOLD

  • Thread starter Thread starter a
  • Start date Start date
A

a

I want to have a macro that will set the smallest number in a row (or
in a column) of selected text to BOLD. For example, with A1 = 1,B1 =
2, C1 = 3, D1 = 4 I want the macro to set Cell A1 to be bolded.

Art
 
Art,
This macro will conditional format the selected range to make minimum value
bold.

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

HTH
Cecil
 
These two subs will apply conditional formatting on the either the selected
column or row to accomplish what you requested. Much later than Cecil, but
I spent so much time I had to at least send them off! If you add to the row
or column, you will need to re-run to extend the formatting to these cells.

Sub format_col()

Dim last_col As Long
Dim col_range As Range

last_col = Selection.Column
Set col_range = Range(Cells(1, last_col), Cells(Cells(Rows.Count,
last_col).End(xlUp).Row, last_col))
With col_range
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,
Formula1:="=MIN(" & col_range.Address & ")"
.FormatConditions(1).Font.Bold = True
End With

End Sub

Sub format_row()

Dim last_row As Long
Dim row_range As Range

last_row = Selection.Row

Set row_range = Range(Cells(last_row, 1), Cells(last_row, Cells(last_row,
Columns.Count).End(xlToLeft).Column))
With row_range
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,
Formula1:="=MIN(" & row_range.Address & ")"
.FormatConditions(1).Font.Bold = True
End With

End Sub

hth,

Doug Glancy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top