简体   繁体   中英

In Excel, to build sub array from start/stop index values in equations

In excel, I have an array of numbers 1 to 5. I use vlookup to find the row index of values 2 and 4. This is the array:

A1=1
A2=2
A3=3
A4=4
A5=5

Now based on the rows the I have found, I want to generate a new array starting from 2 and ending with 4. This is how the new array should look:

B1=2
B2=3
B4=4

How do I do it without VBA?

Thanks

You can use the =OFFSET(A1:A5,1,0,3,1). The first 1 is your index value 2. The 0 is first column (you have only one column so it is 0). The 3 is how many number you want from your first index for form the sub array. The last 1 is how many columns that you wanted. Since you have only one column it is 1. With this you can use the below formula in your B1, B2 and B3 cells. You can replace the first 1 and 3 in the below formula based on your vlookup

=INDEX(OFFSET($A$1:$A$5,1,0,3,1),ROW(),1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM