AOB
Well-known Member
- Joined
- Dec 15, 2010
- Messages
- 660
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
Hi there,
This one's a bit complicated so apologies in advance...
I have a range which looks as per the below. The 'Count' column is populated by an IFERROR / VLOOKUP combo which refers to a pivot table elsewhere in the workbook. For simplicity, let's say this table's range is A1:B25 on a sheet called 'Data' :
<tbody>
</tbody>
Now - I use this data as the source for a column chart. But I only want to chart between the extremities which actually contain a number (i.e., in the above example, I don't want to bother including 12am-7am or 7pm-12am in the chart as the values are all 0 and I don't want to 'squeeze' the good data between 7am and 7pm unnecessarily)
So - I refer to a dynamic named range for the chart's source data and am looking for a decent formula to define the range such that I only get the times of the day which return actual figures.
I had been using the following :
Which works fine - BUT - only if the values in column B are contiguous. So if all my numbers are clumped together between two times, it works fine. The problem is if there is a gap, the formula will only return the first contiguous range of numerically-valued cells.
(i.e. if there is a number at 5am-6am, then nothing until 9am, then more values from 9am onwards, the formula defines the range as just 5am-6am and I lose everything after that in my chart)
I've tried messing around with various combinations - MIN/MAX, INDEX/MATCH etc. - but can't come up with anything which does the trick. Obviously I can't use COUNTA as the column is populated by a formula so Excel sees none of the cells as blanks.
Can anybody suggest a formula to define the dynamic range between the first and last cells in column B which contain a numerical value (regardless of whether there are cells in-between which don't)
As I say, bit complicated (am probably over-complicating to be honest) but I can't fathom how to do it.
Any and all help greatly appreciated!!
Thanks
AOB
This one's a bit complicated so apologies in advance...
I have a range which looks as per the below. The 'Count' column is populated by an IFERROR / VLOOKUP combo which refers to a pivot table elsewhere in the workbook. For simplicity, let's say this table's range is A1:B25 on a sheet called 'Data' :
Time | Count |
12am - 1am | |
1am - 2am | |
2am - 3am | |
3am - 4am | |
4am - 5am | |
5am - 6am | |
6am - 7am | |
7am - 8am | 1 |
8am - 9am | 39 |
9am - 10am | 111 |
10am - 11am | 75 |
11am - 12pm | 82 |
12pm - 1pm | 51 |
1pm - 2pm | 69 |
2pm - 3pm | 180 |
3pm - 4pm | 175 |
4pm - 5pm | 167 |
5pm - 6pm | 67 |
6pm - 7pm | 14 |
7pm - 8pm | |
8pm - 9pm | |
9pm - 10pm | |
10pm - 11pm | |
11pm - 12am |
<tbody>
</tbody>
Now - I use this data as the source for a column chart. But I only want to chart between the extremities which actually contain a number (i.e., in the above example, I don't want to bother including 12am-7am or 7pm-12am in the chart as the values are all 0 and I don't want to 'squeeze' the good data between 7am and 7pm unnecessarily)
So - I refer to a dynamic named range for the chart's source data and am looking for a decent formula to define the range such that I only get the times of the day which return actual figures.
I had been using the following :
=OFFSET('Data'!$B$1,MATCH(TRUE,ISNUMBER('Data'!$B$2:$B$25),0),0,MATCH(1,NOT(ISNUMBER('Data'!$B$2:$B$25))*((ROW('Data'!$B$2:$B$25)-ROW('Data'!$B$1))>MATCH(TRUE,ISNUMBER('Data'!$B$2:$B$25),0)),0)-MATCH(TRUE,ISNUMBER('Data'!$B$2:$B$25),0),1)
Which works fine - BUT - only if the values in column B are contiguous. So if all my numbers are clumped together between two times, it works fine. The problem is if there is a gap, the formula will only return the first contiguous range of numerically-valued cells.
(i.e. if there is a number at 5am-6am, then nothing until 9am, then more values from 9am onwards, the formula defines the range as just 5am-6am and I lose everything after that in my chart)
I've tried messing around with various combinations - MIN/MAX, INDEX/MATCH etc. - but can't come up with anything which does the trick. Obviously I can't use COUNTA as the column is populated by a formula so Excel sees none of the cells as blanks.
Can anybody suggest a formula to define the dynamic range between the first and last cells in column B which contain a numerical value (regardless of whether there are cells in-between which don't)
As I say, bit complicated (am probably over-complicating to be honest) but I can't fathom how to do it.
Any and all help greatly appreciated!!
Thanks
AOB