Find largest number and manipulate cell

warpedone

Board Regular
Joined
May 1, 2002
Messages
139
I'm trying to find the largest of four values from b3:b6 and make the contents of the largest bold.

Right now I just compare the values of each cell with if statements and selectt the largest that way.

Is there a better way to do this?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The only way those cells are highlighted is if you are doing more than bolding. If you are colouring patterns as well then go with my original formula.

A bold blank cell looks no different to a blank cell that isn't bold, so what else are you doing to it?
 
Upvote 0
warpedone said:
I meant the conditional formatting worked - I'll try the code.

I think I need the code (in lieu of a formula) because each time the workbook is opened, a macro wipes the contents from the previous user, thus, the formula in a cell would be erased.

Depends on how the cells are cleared (clearcontents or delete?)
 
Upvote 0
The code is not stored in the cells themselves but is behind the scenes. If you physically deleted the cells (which i doubt you do) then fair comment, but if you are just clearing out the cells then use the formulas as suggested.
 
Upvote 0
Using Edit>Clear>Content WILL NOT remove the conditonal formatting. Only using Edit>Clear>All or Edit>Clear>Format in your opening macro will remove it. Just make sure you don't use the latter two, and you won't need a macro to reinstate the conditional formatting. Just use either my, Oaktree's or Ken's conditional formatting one time, and it will remain on your "cleared" worksheet and will perform as desired when you enter new data.

Barry
 
Upvote 0
I used this:

Dim rng1, rng2 As Range
Dim cel1, cel2 As Range

Set rng1 = ActiveWorkbook.Sheets("Triangle").Range("b3:b6")
For Each cel1 In rng1
If cel1.Value = Application.WorksheetFunction.Max(rng1) Then
cel1.Select
With Selection.Interior
.ColorIndex = 35
End With
End If
Next

Set rng2 = ActiveWorkbook.Sheets("Triangle").Range("d3:d6")
For Each cel2 In rng2
If cel2.Value = Application.WorksheetFunction.Min(rng2) Then
With Selection.Interior
.ColorIndex = 35
End With
End If
Next


The top part found the biggerst number and highlighted the cell. Now I want to compare D3 through D6 and hightlight the smallest number.

Same code but different range and using min instead of max.
Why won't it work?
 
Upvote 0

Forum statistics

Threads
1,216,015
Messages
6,128,296
Members
449,437
Latest member
Raj9505

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