help with formula dealing with consecutive duplicates (very advanced problem)

locksmith55

New Member
Joined
Mar 6, 2022
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to make a formula that can detect consecutive duplicate values in excel. Once this is detected I want it to only return the lowest value for "LOW" and highest values for "HIGH".
Any way this is possible to do with helper colums and formulas?

In the data below I have shown how I want the data to turn out.
mrexcel problem .xlsx
ABCDEFG
1DATAHOW I WANT IT TO LOOK
2VALUELOW/HIGHTIMEVALUELOW/HIGHTIME
33.46HIGH10:20 AM3.46HIGH10:20 AM
42.9LOW11:01 AM2.9LOW11:01 AM
53.08HIGH11:12 AM3.08HIGH11:12 AM
62.77LOW11:40 AM2.64LOW11:57 AM
72.64LOW11:57 AM2.98HIGH12:55 PM
82.95HIGH12:39 PM2.53LOW1:35 PM
92.98HIGH12:55 PM2.89HIGH2:04 PM
102.53LOW1:35 PM2.46LOW2:47 PM
112.62LOW2:04 PM
122.89HIGH2:04 PM
132.68LOW2:22 PM
142.46LOW2:47 PM
Sheet1
Cell Formulas
RangeFormula
E2:G5E2=A2
E6:G6E6=A7
E7:G8E7=A9
E9:G9E9=A12
E10:G10E10=A14
C3C3=TIME(10,20,0)
C4C4=TIME(11,1,0)
C5C5=TIME(11,12,0)
C6C6=TIME(11,40,0)
C7C7=TIME(11,57,0)
C8C8=TIME(12,39,0)
C9C9=TIME(12,55,0)
C10C10=TIME(13,35,0)
C11:C12C11=TIME(14,4,0)
C13C13=TIME(14,22,0)
C14C14=TIME(14,47,0)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
E1 is a array formula (in 2021, you don't have to add CTRL+Shift+Enter), so the cells around must be empty otherwise you get a "overloop error"

Map1
ABCDEFG
1DATAVALUELOW/HIGHtijd
2VALUELOW/HIGHtijd3.46HIGH10:20 AM
33.46HIGH10:20 AM2.9LOW11:01 AM
42.9LOW11:01 AM3.08HIGH11:12 AM
53.08HIGH11:12 AM2.64LOW11:57 AM
62.77LOW11:40 AM2.98HIGH12:55 PM
72.64LOW11:57 AM2.62LOW2:04 PM
82.95HIGH12:39 PM2.89HIGH2:04 PM
92.98HIGH12:55 PM2.46LOW2:47 PM
102.53LOW1:35 PM
112.62LOW2:04 PM
122.89HIGH2:04 PM
132.68LOW2:22 PM
142.46LOW2:47 PM
15
Blad1
Cell Formulas
RangeFormula
E1:G9E1=FILTER(A2:C14,B2:B14<>B3:B15)
C3C3=TIME(10,20,0)
C4C4=TIME(11,1,0)
C5C5=TIME(11,12,0)
C6C6=TIME(11,40,0)
C7C7=TIME(11,57,0)
C8C8=TIME(12,39,0)
C9C9=TIME(12,55,0)
C10C10=TIME(13,35,0)
C11:C12C11=TIME(14,4,0)
C13C13=TIME(14,22,0)
C14C14=TIME(14,47,0)
Dynamic array formulas.
 
Upvote 0
Solution
Why is the 2.62 in row 11 marked as a LOW? The value in row 10 is lower so should row 11 not be HIGH?

Your helper formula for column D. Paste the formula into cel D3 and copy it down.
VBA Code:
=IF(OR(AND($B3="HIGH",$B4="HIGH"),AND($B3="LOW",$B4="LOW")),$D2,$D2+1)

And the formula for cell E3. This formula can then be dragged into the other columns and rows.
VBA Code:
=INDEX(A:A;MATCH(ROW()-2;$D:$D;0);1)


edited to add:
Simplification:
VBA Code:
=IF($B3=$B4,$D2,$D2+1)
 
Last edited:
Upvote 0
Why is the 2.62 in row 11 marked as a LOW? The value in row 10 is lower so should row 11 not be HIGH?

Your helper formula for column D. Paste the formula into cel D3 and copy it down.
VBA Code:
=IF(OR(AND($B3="HIGH",$B4="HIGH"),AND($B3="LOW",$B4="LOW")),$D2,$D2+1)

And the formula for cell E3. This formula can then be dragged into the other columns and rows.
VBA Code:
=INDEX(A:A;MATCH(ROW()-2;$D:$D;0);1)


edited to add:
Simplification:
VBA Code:
=IF($B3=$B4,$D2,$D2+1)
I am getting this error for the index function. I have office 365
fsfsdfsdfsdfsdfsd.PNG
 
Upvote 0
I am getting this error for the index function. I have office 365
View attachment 59902
Why is the 2.62 in row 11 marked as a LOW? The value in row 10 is lower so should row 11 not be HIGH?

Your helper formula for column D. Paste the formula into cel D3 and copy it down.
VBA Code:
=IF(OR(AND($B3="HIGH",$B4="HIGH"),AND($B3="LOW",$B4="LOW")),$D2,$D2+1)

And the formula for cell E3. This formula can then be dragged into the other columns and rows.
VBA Code:
=INDEX(A:A;MATCH(ROW()-2;$D:$D;0);1)


edited to add:
Simplification:
VBA Code:
=IF($B3=$B4,$D2,$D2+1)
Nevermind, i'm just stupid. My excel only works with "," instead of ";". But yeah, you are correct I meant to mark 2.53 as LOW instead of 2.62. Any way to make formula work with that? Thank for help!
 
Upvote 0
E1 is a array formula (in 2021, you don't have to add CTRL+Shift+Enter), so the cells around must be empty otherwise you get a "overloop error"

Map1
ABCDEFG
1DATAVALUELOW/HIGHtijd
2VALUELOW/HIGHtijd3.46HIGH10:20 AM
33.46HIGH10:20 AM2.9LOW11:01 AM
42.9LOW11:01 AM3.08HIGH11:12 AM
53.08HIGH11:12 AM2.64LOW11:57 AM
62.77LOW11:40 AM2.98HIGH12:55 PM
72.64LOW11:57 AM2.62LOW2:04 PM
82.95HIGH12:39 PM2.89HIGH2:04 PM
92.98HIGH12:55 PM2.46LOW2:47 PM
102.53LOW1:35 PM
112.62LOW2:04 PM
122.89HIGH2:04 PM
132.68LOW2:22 PM
142.46LOW2:47 PM
15
Blad1
Cell Formulas
RangeFormula
E1:G9E1=FILTER(A2:C14,B2:B14<>B3:B15)
C3C3=TIME(10,20,0)
C4C4=TIME(11,1,0)
C5C5=TIME(11,12,0)
C6C6=TIME(11,40,0)
C7C7=TIME(11,57,0)
C8C8=TIME(12,39,0)
C9C9=TIME(12,55,0)
C10C10=TIME(13,35,0)
C11:C12C11=TIME(14,4,0)
C13C13=TIME(14,22,0)
C14C14=TIME(14,47,0)
Dynamic array formulas.
Does this work if I want 2.53 as LOW instead of 2.62? I mistyped in my post..
 
Upvote 0
perhaps this is better, bit it'll not be an answer to your bigger question to find the ultimate top or bottom in a longer range. I think you need VBA with adjustable parameters to do so, but i can't remember why that wasn't allowed, was it a Mac ?
Map1
ABCDEFG
1DATA33,460
2VALUELOW/HIGHtijd-42,900
33,46HIGH10:20 AM53,080
42,9LOW11:01 AM-62,640
53,08HIGH11:12 AM82,980
62,77LOW11:40 AM-102,530
72,64LOW11:57 AM122,890
82,95HIGH12:39 PM-13#VERW!
92,98HIGH12:55 PM-15-
102,53LOW1:35 PM
112,62LOW2:04 PM
122,89HIGH2:04 PM
132,68LOW2:22 PM
142,46LOW2:47 PM
Blad1
Cell Formulas
RangeFormula
E1:E9E1=FILTER(IF(B3:B20<>B2:B19,IF(B3:B20="high",1,-1)*ROW(B3:B20),"~"),ISNUMBER(IF(B3:B20<>B2:B19,IF(B3:B20="high",1,-1)*ROW(B3:B20),"~")))
F1:F9F1=IF(COUNT(E1:E2)=2,IF(E1>0,MAX(OFFSET($A$1,E1-1,,-(E2-E1),)),MIN(OFFSET($A$1,-E1-1,,(E2+E1),))),"-")
C3C3=TIME(10,20,0)
C4C4=TIME(11,1,0)
C5C5=TIME(11,12,0)
C6C6=TIME(11,40,0)
C7C7=TIME(11,57,0)
C8C8=TIME(12,39,0)
C9C9=TIME(12,55,0)
C10C10=TIME(13,35,0)
C11:C12C11=TIME(14,4,0)
C13C13=TIME(14,22,0)
C14C14=TIME(14,47,0)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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