# Search tidal data

#### MLC12345

##### New Member
Hi,

I have a database of tidal data, i.e. the time with corresponding tide level, every 5 min a day. If you plot this data, you get a sinusoidal curve. I would like to be able to input a certain day + tide level and get the times back in which the tide is lower than this level. For example;
input: 09/09/14; 2.4m
output: from 0:05 to 9:25 and from 12:00 to 21:20

So this means that between 0:05 and 9:25 the tide is lower than 2.4m and between 12:00 and 21:20 the tide is again lower than 2.4m.
Since there are 2 high tides a day, I should always get 2 time intervals... I will also sometimes get 2.5 time intervals (e.g. if the tide is low again at midnight).

Help on this one would be greatly appreciated...

Thanks!
Marie

### 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"

#### Vidar

##### Well-known Member
Hi Marie

My suggestion assumes that your Dates are in column A, Time in column B and Tide Level in column C.
And if your input date is in cell E2, and Tide Level in cell F2, then try this array formula (must be confirmed with Ctrl+Shift+Enter)
If you need more than 5000 rows then adjust the formula accordingly.

="From "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),"h:mm")&" to "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 > F2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 < F2,\$B\$2:\$B\$241)),1),\$B\$2:\$B\$5000))),1),"h:mm")&", and from "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > =SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 > F2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 < F2,\$B\$2:\$B\$241)),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$5000))),1),"h:mm")&" to "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 > \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$241=\$E\$2,IF(\$C\$2:\$C\$241 < \$F\$2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 > F2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 < F2,\$B\$2:\$B\$241)),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$5000))),1),"h:mm")&IFERROR(", and from "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$241=\$E\$2,IF(\$C\$2:\$C\$241 > \$F\$2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=\$E\$2,IF(\$C\$2:\$C\$241 < \$F\$2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 > F2,IF(\$B\$2:\$B\$241 > SMALL(IF(\$A\$2:\$A\$241=E2,IF(\$C\$2:\$C\$241 < F2,\$B\$2:\$B\$241)),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$241))),1),\$B\$2:\$B\$5000))),1),"h:mm"),"")

Vidar

Last edited:

#### Vidar

##### Well-known Member
If you need more than 5000 rows then adjust the formula accordingly.
Vidar

I noticed that not all my ranges went to row 5000. So here is the edited formula. Remember to confirm with Ctrl+Shift+Enter.

="From "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),"h:mm")&" to "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 > F2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),\$B\$2:\$B\$5000))),1),"h:mm")&", and from "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > =SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 > F2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),"h:mm")&" to "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 > \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 > F2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),"h:mm")&IFERROR(", and from "&TEXT(SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 > \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=\$E\$2,IF(\$C\$2:\$C\$5000 < \$F\$2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 > F2,IF(\$B\$2:\$B\$5000 > SMALL(IF(\$A\$2:\$A\$5000=E2,IF(\$C\$2:\$C\$5000 < F2,\$B\$2:\$B\$5000)),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),\$B\$2:\$B\$5000))),1),"h:mm"),"")

#### MLC12345

##### New Member
THANK YOU VIDAR! It works perfectly! #### Vidar

##### Well-known Member
You're welcome  Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

### Forum statistics

1,164,675
Messages
5,838,716
Members
430,566
Latest member
ChanchalSingh ### 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.

### Which adblocker are you using?    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

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