Macro- max value

  • Thread starter Thread starter Joyce
  • Start date Start date
J

Joyce

Can anyone tell me the VB code for finding the maximun
value in a column and highlight it in red? I have to put
it in Macro.

Thanks!
 
Try something like:

Sub FindMax()
Dim maxno As Long
Dim maxrow As Long
Set rng = Range("A:A")
maxno = Application.WorksheetFunction.Max(rng)
maxrow = rng.Find(What:=maxno).Row
With Cells(maxrow, "A")
.Font.ColorIndex = 3
.Font.Bold = True
End With
End Sub

To use it, press ALT+F11, go to Insert > Module, and paste
in the code. Then run the macro in Excel.

HTH
Jason
Atlanta, GA
 
One way

Sub hiliteit()
columns(1).interior.colorindex=0' to clear
Columns(1).Find(Application.Max(Columns(1))) _
..Interior.ColorIndex = 6
End Sub
 
Hi
just curious: Why don't you use conditional formating for this?
 

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