Find High & Low in different ranges meeting certain criteria

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,213
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
This thread I have cross posted Cell value dependent on multiple conditions

2 input ranges are there in my Worksheet (tab named ‘HL’)

Range 1: D10:M10 which generates either of 1 or 0 or “” (null) with a condition that 1 would be generated in a ‘contiguous’ manner i.e. if 1 is generated in K10 then D10:J10=1
Range 2: 9 sets with each set of 2 rows. The 9 sets are D4:M6; D12:M14; D16:M18; D20:M22; D24:M26; D28:M30; D32:M34; D36:M38 & D40:M42. These 9 sets (with 2 rows each) generates a numerical value >=0 or “” (null)
Answers needed in 9 ranges (Range 3) each having 2 rows. 9 ranges (Range 3) are T4 & T6; T12 & T14; T16 & T18; T20 & T22; T24 & T26; T28 & T30; T32 & T34; T36 & T38; T40 & T42
Criteria’s:

  • Code should find the cell in D10:M10 with last “1” (here in example K10)
  • Then, corresponding ‘cells’ in Range 2:D4:M4 & D6:M6 (here K4 & K6)..allow me to call K4 & K6 as ‘base cells’ for further correspondence purpose only & similarly for other 8 sets of Range 2 i.e. D12:M12 & D14:M14 (here K12 & K14) & so on up to ……. D40:M40 & D42:M42 (here K40 & K42)
  • In 4th row (corresponding to base cell K4), check the ‘1st cell’ on its left hand side of K4 (J4 in this case) findhigh=IF(AND(J4>K4,J6<K6),J4,check ‘next cell’ on its left hand side)
  • findlow=IF(AND(J4>K4,J6<K6),J6,check ‘next cell’ on its left hand side)
[*]check ‘next cell’ on its left hand side=IF(AND(I4>K4,I6<K6),I4) for findhigh & =IF(AND(I4>K4,I6<K6),I6) for findlow
  • IF no cells in D4:J4 (in this case up to J4 since the corresponding base cell is K4) meets the criteria, then ‘base cells’ becomes J4 & J6 for code’s further checking purpose.
  • Follow criteria #3 i.e. check the ‘1st cell’ on left hand side of J4 (I4 in this case)
  • findhigh=IF(AND(I4>J4,I6<J6),I4,check ‘next cell’ on its left hand side)
  • findlow=IF(AND(I4>J4,I6<J6),I6,check ‘next cell’ on its left hand side)
  • check ‘next cell’ on its left hand side=IF(AND(H4>J4,H6<J6),H4) for findhigh & =IF(AND(H4>J4,H6<J6),H6) for findlow
  • Follow criteria #4 i.e. IF no cells in D4:I4 (in this case up to I4 since the corresponding base cell is now J4) meets the criteria, then ‘base cells’ becomes I4 & I6 for code’s further checking purpose….& so on
  • findhigh =’Null’ & findlow=’Null’ IF no criteria is met (example shown in row #36 & 38)
  • findhigh =’Null’ & findlow=’Null’ IF the ‘current’ base cell/(s)=0 or “” (null)
  • I tried but was unable to write the correct ‘complete’ code (wrong answers in row #12 & 14; row #28 &30)
Appreciate your patience.
HighLow v3.xlsm
DEFGHIJKLMNTWXY
1Answer given by current codeCorrect Answer
3
4488.90488.00485.00650.00650.00530.00580.00600.000.000.00650650.00
6476.80475.00477.00498.00499.00520.00501.00500.000.000.00499499.00
9
101111111100
11
1284.4584.0085.0080.0075.0099.0098.00100.000.000.00Null99.00
1481.5080.0070.0070.0070.0089.0090.0095.000.000.00Null89.00
15
16759.50720.00759.00730.00780.00777.00800.00769.000.000.00800800.00
18748.80780.00749.00750.00750.00751.00600.00650.000.000.00600600.00
19
20354.50320.00330.00340.00350.00320.00325.00329.000.000.00350350.00
22346.50350.00320.00321.00300.00300.00301.00302.000.000.00300300.00
23
24364.30365.00348.00338.00400.00329.00355.00356.000.000.00365365.00
26354.80320.00320.00300.00353.00305.00350.00352.000.000.00320320.00
27
28235.95235.00240.00250.00260.00255.00220.00219.000.000.00Null260.00
30226.50227.00230.00230.00240.00245.00210.00209.000.000.00Null240.00
31
32132.60136.00160.00165.00155.00156.00158.00145.000.000.00155155.00
34123.80126.00131.00145.00150.00155.00151.00151.000.000.00150150.00
35
36223.25220.00215.00232.00212.00241.00210.00250.000.000.00NullNull
38219.15210.00200.00200.00200.00201.00200.00201.000.000.00NullNull
39
4035091350003400034600346003455034558345550035091.4535091.45
423455434600339603455734556344493455734555003455434554.00
HL
Cell Formulas
RangeFormula
T4T4=findhigh($D$4:$M$4,$D$6:$M$6,$D$10:$M$10)
T6T6=findlow($D$4:$M$4,$D$6:$M$6,$D$10:$M$10)
T12T12=findhigh($D$12:$M$12,$D$14:$M$14,$D$10:$M$10)
T14T14=findlow($D$12:$M$12,$D$14:$M$14,$D$10:$M$10)
T16T16=findhigh($D$16:$M$16,$D$18:$M$18,$D$10:$M$10)
T18T18=findlow($D$16:$M$16,$D$18:$M$18,$D$10:$M$10)
T20T20=findhigh($D$20:$M$20,$D$22:$M$22,$D$10:$M$10)
T22T22=findlow($D$20:$M$20,$D$22:$M$22,$D$10:$M$10)
T24T24=findhigh($D$24:$M$24,$D$26:$M$26,$D$10:$M$10)
T26T26=findlow($D$24:$M$24,$D$26:$M$26,$D$10:$M$10)
T28T28=findhigh($D$28:$M$28,$D$30:$M$30,$D$10:$M$10)
T30T30=findlow($D$28:$M$28,$D$30:$M$30,$D$10:$M$10)
T32T32=findhigh($D$32:$M$32,$D$34:$M$34,$D$10:$M$10)
T34T34=findlow($D$32:$M$32,$D$34:$M$34,$D$10:$M$10)
T36T36=findhigh($D$36:$M$36,$D$38:$M$38,$D$10:$M$10)
T38T38=findlow($D$36:$M$36,$D$38:$M$38,$D$10:$M$10)
T40T40=findhigh($D$40:$M$40,$D$42:$M$42,$D$10:$M$10)
T42T42=findlow($D$40:$M$40,$D$42:$M$42,$D$10:$M$10)
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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