ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Partition data range by an indicator variable (https://www.excelbanter.com/excel-programming/413299-partition-data-range-indicator-variable.html)

Arne

Partition data range by an indicator variable
 
The formula =OFFSET(Data!$R$1,1,0,COUNTA(Data!$R:$R)-1) returns the array of
data in column R. As I add data points, the size of the array changes to
match all of the data entered.

I would like to subset the data range into non-overlaping ranges by using an
indicator variable (1, 2, ...) in a different column.

Thanks,

Arne

Doug Glancy

Partition data range by an indicator variable
 
Arne,

I think this is what you want. It assumes you are looking for the indicator
variable 1 on column A:

=INDEX(Sheet1!$A:$A,MATCH(1,Sheet1!$A:$A,-1)):OFFSET(INDEX(Sheet1!$A:$A,MATCH(1,Sheet1!$A:$A ,-1)),COUNTIF(Sheet1!$A:$A,1)-1,0)

hth,

Doug

"Arne" wrote in message
...
The formula =OFFSET(Data!$R$1,1,0,COUNTA(Data!$R:$R)-1) returns the array
of
data in column R. As I add data points, the size of the array changes to
match all of the data entered.

I would like to subset the data range into non-overlaping ranges by using
an
indicator variable (1, 2, ...) in a different column.

Thanks,

Arne




Arne

Partition data range by an indicator variable
 
Doug,

I couldn't get the formula you suggested to work, but realized that I was
interpreting the syntax to match incorrectly. The expressions I came up with
we

=IF(ISNA(MATCH(1,Data!$B:$B)),OFFSET(Col_Date,1,0, COUNTA(Data!$A:$A)-1),OFFSET(Col_Date,1,0,MATCH(1,Data!$B:$B)-1))


=IF(ISNA(MATCH(2,Data!$B:$B,0)),IF(ISNA(MATCH(1,Da ta!$B:$B,0)),#N/A,OFFSET(Col_Date,MATCH(1,Data!$B:$B,0),0,COUNTA(D ata!$A:$A)-MATCH(1,Data!$B:$B,0))),OFFSET(Col_Date,MATCH(1,Da ta!$B:$B,0),0,MATCH(2,Data!$B:$B)-MATCH(1,Data!$B:$B)))


=IF(ISNA(MATCH(2,Data!$B:$B,0)),#N/A,OFFSET(Col_Date,MATCH(2,Data!$B:$B,0),0,COUNTA(D ata!$A:$A)-MATCH(2,Data!$B:$B,0)))


This returns arrays of the date stored in column A, where Col_Date is the
location of the column header. The indicator variable is in column B. The
possible indicator variables are none, 1, 2. This yields a maximum of three
partitions.

Thanks,

Arne

"Doug Glancy" wrote:

Arne,

I think this is what you want. It assumes you are looking for the indicator
variable 1 on column A:

=INDEX(Sheet1!$A:$A,MATCH(1,Sheet1!$A:$A,-1)):OFFSET(INDEX(Sheet1!$A:$A,MATCH(1,Sheet1!$A:$A ,-1)),COUNTIF(Sheet1!$A:$A,1)-1,0)

hth,

Doug

"Arne" wrote in message
...
The formula =OFFSET(Data!$R$1,1,0,COUNTA(Data!$R:$R)-1) returns the array
of
data in column R. As I add data points, the size of the array changes to
match all of the data entered.

I would like to subset the data range into non-overlaping ranges by using
an
indicator variable (1, 2, ...) in a different column.

Thanks,

Arne






All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com