Highlight MAX in each contiguous range.

bigmyk2k

Board Regular
Joined
Feb 9, 2012
Messages
104
I am working in a spreadsheet analyzing rainfall data. This sheet has 50,000+ rows, and ~35 columns.

About half of the columns are formulaic, and are conditionally formatted to highlight based on Min>>Max.

As you travel down a column, you may come across anywhere from 3-300 contiguous cells that are displaying a result, while the IF function in the rest has left them blank.

Currently, every cell in all 50,000+ rows of each column is highlighting on the same scale. Is there anyway to automatically parse the highlight so that each contiguous group of cells in each column has only it's own Max highlighted?

Certainly, this is possible manually, but that is completely absurd to think of doing.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Why not use Pivot table to get the min and max values in your dataset?

Overall Min and Max would be pretty easy, I'm looking for Max values for each and every discrete period.

For instance, I'm working with about 2 years worth of rain data. In every year, there are 2 6-Month periods, 12 1-Month periods, 365 24-Hour periods, etc. However, for every one of those, there are 35,040 rolling average periods (4 15-min periods per hour, 24 hours per day, 365 days per year).

My cell formula only displays a value above a certain threshold, so there are ranges of varying length that show a result, and ranges of varying length that don't. What I need to find is the local maximum in every contiguous range of cells that show a result.
 
Upvote 0
That is no answer to my question.

Why not use Pivot table to get the min and max values in your dataset?
 
Upvote 0
That is no answer to my question.

Why not use Pivot table to get the min and max values in your dataset?

The data is not tabulated in such a way as to facilitate this. It has not contiguous rows, and several cross references.
 
Upvote 0
Is it possible for you to re-arange the data, so a pivot table (a very powerfull tool in excel) can be used.

It can be done (depend on the lay out of the data) with VBA.
 
Upvote 0
I am working in a spreadsheet analyzing rainfall data. This sheet has 50,000+ rows, and ~35 columns.

About half of the columns are formulaic, and are conditionally formatted to highlight based on Min>>Max.

As you travel down a column, you may come across anywhere from 3-300 contiguous cells that are displaying a result, while the IF function in the rest has left them blank.

Currently, every cell in all 50,000+ rows of each column is highlighting on the same scale. Is there anyway to automatically parse the highlight so that each contiguous group of cells in each column has only it's own Max highlighted?

Certainly, this is possible manually, but that is completely absurd to think of doing.
I am not 100% certain about your data as it relates to the formulas, but assuming you are interested in only finding the maximums of contiguous ranges of constants (ignoring the formulas), then this might work for you...
Code:
Sub HighlightMaximumsInContiguousColumnRanges()
  Dim C As Long, LastCol As Long, Arr As Range
  LastCol = Cells.Find("*", , xlFormulas, , xlByColumns, xlPrevious).Column
  Application.ReplaceFormat.Clear
  Application.ReplaceFormat.Interior.ColorIndex = 6
  For C = 1 To LastCol
    For Each Arr In Columns(C).SpecialCells(xlConstants).Areas
      Arr.Replace WorksheetFunction.Max(Arr), "", xlWhole, , , , False, True
    Next
  Next
  Application.ReplaceFormat.Clear
End Sub
 
Upvote 0
It can possibly be done, but it isn't my data, and the format is ideal for most of what we currently use it for.
This would be a little taste, but assume that every cell outside of the first two rows has a formula in it.
Data - RG 3

*ABDEFGHIJKLMNOPQRSTUVWXYZAAAB
11TimeRainfall (IN)30-MIN1-HR2-HR3-HR6-HRXXXXXX24-HR48-HR72-HR5-DAY10-DAYXXX15-MIN30-MIN1-HR2-HR3-HR6-HRXXX18-HR24-HRXXX72-HR5-DAY
12XXX0.00****XXX****XXXXXXXXX*-----XXXXXX-XXX-XXX-
1303/27/2014 1:30 PM0.00XXX****XXX***XXX**XXX-----XXX------
14XXXXXX0.00***XXX**XXX****XXX--XXX--XXX-XXX----
1503/27/2014 2:00 PM0.000.000.00*****XXX****XXX-XXXXXX--XXX-XXX-XXX-XXX
1603/27/2014 2:15 PM0.00XXX0.00*XXX*********---XXX-XXX--XXX---
1703/27/2014 2:30 PM0.000.000.00***********XXX-XXX----XXX----
18XXXXXX0.000.00********XXXXXXXXX-------XXXXXX---

<tbody>
</tbody>



Excel tables to the web >> Excel Jeanie HTML 4
 
Last edited:
Upvote 0
Hey Rick, thanks for taking a look. I'm not great with VBA, can you give me an idea of what that is going to do?

The columns I'm looking in are R through AB, would that have an effect on what I enter?
Also, as stated elsewhere, I don't want to touch or rearrange the data, just call out/highlight the local maxima.
I am actually pretty close to getting this with a highlight cells rule, but it highlights the cell before (above) the one I'm looking for, and sometimes skips a highlight altogether.
 
Last edited:
Upvote 0
Hey Rick, thanks for taking a look. I'm not great with VBA, can you give me an idea of what that is going to do?
It is going to make the background color of each cell containing a maximum value within its own column-wise contiguous region yellow. No data is touched or move.


The columns I'm looking in are R through AB, would that have an effect on what I enter?
I have to change the code so it looks in the correct columns. Here is the revised macro...
Code:
Sub HighlightMaximumsInContiguousColumnRanges()
  Dim C As Long, Arr As Range
  Application.ReplaceFormat.Clear
  Application.ReplaceFormat.Interior.ColorIndex = 6
  For C = 18 To 28
    For Each Arr In Columns(C).SpecialCells(xlConstants).Areas
      Arr.Replace WorksheetFunction.Max(Arr), "", xlWhole, , , , False, True
    Next
  Next
  Application.ReplaceFormat.Clear
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,803
Members
449,048
Latest member
greyangel23

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