+ Reply to Thread
Results 1 to 18 of 18

extracting every 5th value of a vertical array into another array

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Smile extracting every 5th value of a vertical array into another array

    I have a vertical named 1 by 5000 array (my_array) and would Iike to extract every 5th value into another named array. Is this possible by insering a formula into the name manager without resorting to a number of formulas in individual cells?

    Also, if the above is possible, how would I extract maximum of every 5 entires of "my_array" and put them into a new array? So. for example, the first entry in "new_array" would be =max(A1:A5), the second entry would be =max(A6:A10), and so on....

    Thank you
    Last edited by luv2glyd; 06-29-2010 at 11:04 AM.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: extracting every 5th value of a vertical array into another array

    You can use the attached UDF. For example, define

    myArray Refers to ==Sheet1!$A$1:$A$5000

    EveryFive Refers to =DisjointRange(INDEX(myArray,1), INDEX(myArray,6), 1000)

    As a non-contiguous range, you won't be able to do all the same things you can do with a contiguous range.

    Please Login or Register  to view this content.
    Last edited by shg; 06-27-2010 at 06:37 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Thank you. Did you mean

    =DisjointRange(INDEX(myArray,1), INDEX(myArray,6), 1000) ?

    If I try to enter

    =DisjointRange(=DisjointRange(INDEX(myArray,1), INDEX(myArray,6), 1000))
    into the name manager, it gives me an error message.

    =DisjointRange(INDEX(myArray,1), INDEX(myArray,6), 1000) works, but unfortunately considerably slows down the computer...... are there any other ways of accomplishing what I'm after? Perhaps without using VB?

    Thank you
    Last edited by luv2glyd; 06-26-2010 at 05:28 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: extracting every 5th value of a vertical array into another array

    Yes, corrected below.

    but unfortunately considerably slows down the computer
    No surprise; the Union function itself is slow. What are you doing with it?

  5. #5
    Registered User
    Join Date
    11-11-2007
    Posts
    6

    Red face Re: extracting every 5th value of a vertical array into another array

    luv2glyd -

    This named formula will produce a range of every fifth element of your named vertical array:

    =INDEX(NamedVerticalArray,ROW(INDIRECT("1:"&1000))*5)

    Regards,

    Daniel Ferry
    excelhero.com/blog/

  6. #6
    Registered User
    Join Date
    06-28-2010
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: extracting every 5th value of a vertical array into another array

    =index(datarange,rows(a$1:a1),1)
    copy the formula

  7. #7
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Quote Originally Posted by shg View Post
    What are you doing with it?
    i'm plotting the result (every fifth value) on a chart, and as the data in the source vector changes, need to be able to see the result (every fifth value plotted) almost instanteneously, as i'm sorting throught 100th of chart manually (visual check - not much excel can do here)

  8. #8
    Registered User
    Join Date
    11-11-2007
    Posts
    6

    Re: extracting every 5th value of a vertical array into another array

    Were you able to make use of the formula I posted above?

    It should work perfectly as a named source for your chart.

    Regards,
    Daniel Ferry
    excelhero.com/blog/

  9. #9
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Quote Originally Posted by ExcelHero View Post
    luv2glyd -

    This named formula will produce a range of every fifth element of your named vertical array:
    =INDEX(NamedVerticalArray,ROW(INDIRECT("1:"&1000))*5)

    /
    Daniel,

    I inserted the formula into the name manager, though it does not seem to work... It seems to only contain one value in it vs. 1000. I tried to have a chart refer to it, as my ultimte goal is to be able to plot it, but was given an error...........

    Could you attach a worksheet with an example?

  10. #10
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Quote Originally Posted by siva972377 View Post
    =index(datarange,rows(a$1:a1),1)
    copy the formula
    I'm actually looking to name a range with a formula vs. generating a new column of data in the cells of the worksheet.

  11. #11
    Registered User
    Join Date
    11-11-2007
    Posts
    6

    Re: extracting every 5th value of a vertical array into another array

    Ahh,

    You may need to change it slightly so that the chart can figure out what to do with it:

    =INDEX(NamedVerticalArray,ROW(INDIRECT("'Some Sheet'1:"&1000))*5)

    Notice that 'Some Sheet' has single quotes around it and the term Some Sheet should be replaced by the name of one of the worksheets in your workbook. It does not matter which one.

    Then when you go to apply the source in the chart you need to do it like this:

    ='Some Sheet'!Name

    where Name is the name you gave my formula.

    Regards,

    Daniel Ferry
    excelhero.com/blog/

  12. #12
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Still no luck.......... attached is a sheet with a graph in question highlited in yellow. I copied the formuls from your post, and named the sheet "Some Sheet" just so there are no typos. Assuming everything is correct, I should be able just to change the named range a chart reffers to to EveryFiveAlt. When I try doing that I'm given an error for some reason...
    Last edited by luv2glyd; 06-28-2010 at 01:59 PM.

  13. #13
    Registered User
    Join Date
    11-11-2007
    Posts
    6

    Re: extracting every 5th value of a vertical array into another array

    OK.

    I had to rework it, because while the array formula was working, the chart did not like it.

    The attached approach to the array formula plots fine.

    Regards,
    Daniel Ferry
    excelhero.com

  14. #14
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Awesome!!! Thank you very much! That is one complicated formula This will speed things up quite a bit in what I'm trying to accomplish.

    Is it possible to have this formula refer to myArray vector only, and not the cells in the worksheet? (Withouth going into too much detail, my vector's data in the real Worksheet I'm working with is actually located in secondary "Data" sheet, and the worksheet I'm working in never sees it's values in any of it's cells. myArray's numbers are imported into myArray from another worksheet using INDIRECT function.)

    Also, any ideas on how to make the second part of my question work? The one with the max of every 5 consecutive cells?.......... It's in the first post.

    Thanks again for your help.

  15. #15
    Registered User
    Join Date
    11-11-2007
    Posts
    6

    Re: extracting every 5th value of a vertical array into another array

    OK.

    So here is the named formula that does the first part successfully:

    =N(OFFSET(SheetOfRealArray!$A$1,ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,250))*5-1,0,1,1))

    ...notice SheetOfRealArray. You must replace that to point to wherever your real data is. The other sheet references are not working with your data - they just control how large the resulting array will be.

    The second part (Max every 5) can be done using this modified named formula:

    =MAX(OFFSET(Sheet1!$A$1,ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,250))*5-5,0,5,1))

    I think I'd like to build my reputation here, so if you would not mind to click that do thingy at the right if this was helpful, I'd be grateful. Also, I think you may be interested in my Excel blog:

    http://excelhero.com/blog/

    Regards,
    Daniel Ferry
    excelhero.com/blog/

  16. #16
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Cool!! Let me see if I can make this work with what I'm doing. Thanks again for your help!

    Ok, just did I already cheked out your site - looks pretty cool. I like all the different charts and illusions.

  17. #17
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    I made the first one work like this:

    =N(OFFSET(INDIRECT(data_sheet&"!$A$1"),ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,250))*5-1,0,1,1))

    I have 100's of sheets to cycle throught and can do that just by entering the name of the sheet into cell named "data_sheet"

    Having trouble with the second formula (one using MAX). As with the first one a few posts ago, when trying to plot and set the chart series to this named range, I'm givem an error........ Any idea why it's doing that?....

    Thank you

  18. #18
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extracting every 5th value of a vertical array into another array

    Any suggestions on how to tweak this this named range so I can refer to it in a chart?

    =MAX(OFFSET(Sheet1!$A$1,ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,250))*5-5,0,5,1))

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1