Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Highlight Highest number

Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all those
cells.

Thanks in advance

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Highlight Highest number

Sub ColourMyWorld()
Set myRange = Selection
MyMax = WorksheetFunction.Max(myRange)
For Each Mycell In myRange
If Mycell.Value = MyMax Then
Mycell.Interior.ColorIndex = 3
Mycell.Interior.Pattern = xlSolid
End If
Next
End Sub
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Highlight Highest number

Hi Dave, this macro assumes no header row. You can adjust to suit your
needs, incuding worksheets name or index number and range to be evaluated.
This also allows for more than one cell having the highest single value entry.

Sub mxval()
Set myRng = Worksheets(1).Range("A1:A100")
x = Application.WorksheetFunction.Max(Range("A1:A100") )
For i = 1 To myRng.Rows.Count
If Cells(i, 1).Value = x Then
Cells(i, 1).Interior.ColorIndex = 3
End If
Next
End Sub


"DaveM" wrote:

Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all those
cells.

Thanks in advance

Dave



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Highlight Highest number

Why would you not want to use conditional formatting? It is easy and
dynamic.
__________________________________________________ _____________________

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Highlight Highest number

I need to select cells, then save these to a web page, conditional
formatting will not work for what i'm doing

thanks for the replies, the first 2 replies do nothing even when i've change
the code.




Sub mxval()
Set myRng = Worksheets(1).Range("I2:I2542")
x = Application.WorksheetFunction.Max(Range("I2:I2542" ))
For i = 1 To myRng.Rows.Count
If Cells(i, 1).Value = x Then
Cells(i, 1).Interior.ColorIndex = 3
End If
Next
End Sub

The highest values in the column are I2535 to I2542 yet the code does not
highlight these cells.

Thanks in advance

Dave




"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Why would you not want to use conditional formatting? It is easy and
dynamic.
__________________________________________________ _____________________

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Highlight Highest number

Dave, you will also need to change the column reference from Cells(i, 1) to
Cells(i, 9) to cover Column I. Also make you range reference one cell longer
than your data. For some reason, it doesn't see that last data cell if it is
the last cell in the designated range. i.e. myRng = Range("I2:I2543") I ran
this and it works on my set.

Sub mxval()
Set myRng = Worksheets(1).Range("I2:I2543")
x = Application.WorksheetFunction.Max(Range("I2:I2543" ))
For i = 2 To myRng.Rows.Count + 1
If Cells(i, 9).Value = x Then
Worksheets(1).Cells(i, 9).Interior.ColorIndex = 3
End If
Next
End Sub

"DaveM" wrote:

I need to select cells, then save these to a web page, conditional
formatting will not work for what i'm doing

thanks for the replies, the first 2 replies do nothing even when i've change
the code.




Sub mxval()
Set myRng = Worksheets(1).Range("I2:I2542")
x = Application.WorksheetFunction.Max(Range("I2:I2542" ))
For i = 1 To myRng.Rows.Count
If Cells(i, 1).Value = x Then
Cells(i, 1).Interior.ColorIndex = 3
End If
Next
End Sub

The highest values in the column are I2535 to I2542 yet the code does not
highlight these cells.

Thanks in advance

Dave




"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Why would you not want to use conditional formatting? It is easy and
dynamic.
__________________________________________________ _____________________

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Highlight Highest number

I need to select cells, then save these to a web page, conditional
formatting will not work for what i'm doing


Maybe this function will help you. Pass it the column (as a letter) you want
to parse and it will return a range containing the cells with the highest
value in that column. You can then process the returned range however you
want to.

Function HighestSelection(ColumnLetter As String) As Range
Dim R As Range
Dim MaxValue As Double
Dim CumulativeSelection As String
MaxValue = -1E+308
For Each R In Range(ColumnLetter & ":" & ColumnLetter)
If R.Value MaxValue Then
CumulativeSelection = R.Address
MaxValue = R.Value
ElseIf R.Value = MaxValue Then
CumulativeSelection = CumulativeSelection & "," & R.Address
End If
Next
Set HighestSelection = Range(CumulativeSelection)
End Function


Rick

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Highlight Highest number

My code worked for me! Would you like a file with it in?
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"DaveM" wrote in message
...
I need to select cells, then save these to a web page, conditional
formatting will not work for what i'm doing

thanks for the replies, the first 2 replies do nothing even when i've
change the code.




Sub mxval()
Set myRng = Worksheets(1).Range("I2:I2542")
x = Application.WorksheetFunction.Max(Range("I2:I2542" ))
For i = 1 To myRng.Rows.Count
If Cells(i, 1).Value = x Then
Cells(i, 1).Interior.ColorIndex = 3
End If
Next
End Sub

The highest values in the column are I2535 to I2542 yet the code does not
highlight these cells.

Thanks in advance

Dave




"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Why would you not want to use conditional formatting? It is easy and
dynamic.
__________________________________________________ _____________________

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Highlight Highest number

Thanks All


"Bernard Liengme" wrote in message
...
My code worked for me! Would you like a file with it in?
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"DaveM" wrote in message
...
I need to select cells, then save these to a web page, conditional
formatting will not work for what i'm doing

thanks for the replies, the first 2 replies do nothing even when i've
change the code.




Sub mxval()
Set myRng = Worksheets(1).Range("I2:I2542")
x = Application.WorksheetFunction.Max(Range("I2:I2542" ))
For i = 1 To myRng.Rows.Count
If Cells(i, 1).Value = x Then
Cells(i, 1).Interior.ColorIndex = 3
End If
Next
End Sub

The highest values in the column are I2535 to I2542 yet the code does not
highlight these cells.

Thanks in advance

Dave




"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Why would you not want to use conditional formatting? It is easy and
dynamic.
__________________________________________________ _____________________

"DaveM" wrote in message
. uk...
Hi all

How could i find down column B with a macro the highest number not
Conditional formatting, so if there's 5 cells with 2007 Highlight all
those cells.

Thanks in advance

Dave









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
highlight the highest cell in a column exhub58 Excel Worksheet Functions 1 October 27th 09 02:55 AM
how do i highlight the ten highest numbers in a range? Help Wanted Excel Discussion (Misc queries) 3 May 5th 09 06:39 PM
Highlight highest figures Mamabear Excel Programming 2 May 23rd 07 09:11 AM
Highlight highest / lowest number in a row [email protected] Excel Discussion (Misc queries) 3 April 1st 07 02:00 AM
2 rows, highest No in row 1, then highest number in row 2 relating to that column, possible duplicates John Excel Worksheet Functions 3 August 11th 06 04:34 AM


All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"