+ Reply to Thread
Results 1 to 19 of 19

Array with fixed source range

  1. #1
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Array with fixed source range

    Hi,

    I am trying to get an array formula (in tab 2 in example file) to return a part of a source table only (tab 1 in example file). I wanted to return just the month of May, which comes from rows 15-21 in the source data), but in a way that allows me to insert rows above, below or within the source table (anywhere in the year) without having to change the array manually each time. This would allow me to have several variations of the report created without manually re-typing all of the array formulas each time I made a change in the source data 9there are quite a lot of them).

    In the example spreadsheet attached, in tab 2, the table of array formulas does accomplish this when the changes to the source data are within the desired Month (May), or after it (by addressing the range of rows numbered 15-21 of the source data). I do have to manually refresh the array by dragging the row of formulas in the first row of the array table down each time a change occurs (to recreate the array including the new rows). However, If I insert new rows in months before the target month (in April for example, which is above row 15 of the source data), the month of May will then start further down than row 15. This means that the range of rows used in the array formula will no longer be correct (May might then occupy rows 17-23 for example).

    I was hoping that it was somehow possible to have the array refer to a fixed part of a table in the source data so that changes in the source data were possible. I tried using the 'INDIRECT' function when addressing the array formula, and it did work (it locks the array to the original source cells even if new rows are added), but I was not confident that the INDIRECT function was the right approach (not sure how long it would link to the original cells, and I would have no way to check over time where the original cell was).

    Then I wondered if the array should refer to a named range for the month of May, which would presumably move with the month of May as new rows were added any where in the source data. I tried this, but I am not familiar with named ranges, and it did not work for me as part of the array though I may not have used the named ranges correctly).

    Any suggestions would be appreciated.

    Many thanks
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Array with fixed source range

    That's how I understood you. I added K2, K3, K4 and you can change the year, month and category.
    Look at the attachment.
    Greetings.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    12-23-2003
    Posts
    179

    Re: Array with fixed source range

    In I7 of Expense cat 4 for May control+shift+enter, not just enter, and copy down:

    =IFERROR(SMALL(IF('All Purchases'!$G$7:$G$29=4;IF(ISNUMBER('All Purchases'!$A$7:$A$29);IF('All Purchases'!$A$7:$A$29-DAY('All Purchases'!$A$7:$A$29)+1=(1&$A$6)+0;ROW('All Purchases'!$A$7:$A$29)-ROW('All Purchases'!$A$7)+1)));ROWS($1:1));"")

    In A7 just enter, copy across, and down:

    =IF($I7="";"";INDEX('All Purchases'!$A$7:$J$29;$I7;MATCH(A$4;'All Purchases'!$A$4:$J$4;0)))

    Note 1. If you are on an American system, substitute a comma for a semicolon. Format also the formula cells the same way as the source cells.

  4. #4
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Thank you for this Aladin Akyurek. I can't get the first formula to return anything when I add it to I7, and use ctrl+shift+enter. I have tried to check over it for mistakes, but I don't fully understand the formula to know what to look for. Maybe you wouldn't mind having a second look?
    Last edited by nunez100; 12-15-2018 at 11:13 AM.

  5. #5
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Hi,

    Thank you very much maras_mak, this is a great solution.

    I should have said in the original post that I might want to run the report over the whole financial year. I should have said this, but I was just trying to keep it simple, and I did not realise you would come up with a solution so different form my original approach (my mistake).

    I wonder would your approach be easily adapted to do 12 months at once? One complication is that the financial year runs 6th April 2018 to 5 April 2019. So I have each month separate in the source table, and have April split into two (1st-5th, and 6th-30th). I have attached another example with the source data laid out exactly as it is in my version. Just to recap, at the moment the part of the source data I want to capture is rows 40-165 of the source data, but the problem is that this changes when I add rows before or within this range.

    As a side note, I was also really hoping to be able to have several expense categories included in the report at once (but this is not essential if it complicates it unnecessarily).

    Thank you again for your help, and apologies for not telling you the whole story at the beginning.

    Many thanks
    Attached Files Attached Files
    Last edited by nunez100; 12-15-2018 at 11:14 AM.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    I assume the dates in All purchases A6:a12 should have referred to 2017??

    Ordinary formula in A7, copied across to E7 and then down:

    =IFERROR(INDEX('All Purchases'!A:A,AGGREGATE(15,6,ROW('All Purchases'!$A$2:$A$1000)/(('All Purchases'!$A$2:$A$1000>=DATE(2018,4,6))*('All Purchases'!$A$2:$A$1000<=DATE(2019,4,5))*('All Purchases'!$B$2:$B$1000<>"")*('All Purchases'!$G$2:$G$1000=4)),ROWS(A$7:A7))),"")

    and a similar formula in F7, copied across and down.

    Next FY, change the bits in red.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Forum Contributor
    Join Date
    12-23-2003
    Posts
    179

    Re: Array with fixed source range

    Quote Originally Posted by nunez100 View Post
    Thank you for this Aladin Akyurek. I can't get the first formula to return anything when I add it to I7, and use ctrl+shift+enter. I have tried to check over it for mistakes, but I don't fully understand the formula to know what to look for. Maybe you wouldn't mind having a second look?

    See the attachment...
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    This is great Glenn. Thank you very much.

    I wonder if it would be possible to adapt your formula to reference some input boxes beside the final table? This way I could type the start and finish date, and the expense category to create different permutations of the report (or have a formula refer to somewhere earlier in the sheet). It would be really ideal to be able to include more than one expense category at once if possible (ie. 4, 5 and 6), but maybe this is asking too much.

    Thank you again for your help, I was struggling to figure this one out myself.

    Many thanks

    George

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    Yep. See sheet.

    And, of course... You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Attached Files Attached Files

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    I just noticed that I missed the Category X or category Y bit. It's added now.

    You may need to copy the formulae down further, depnding on the combo chosen...
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Glenn,

    That is amazing, thank you so much. I see you are also based in Norn Iron!

    I will mark this as solved. One last question before I mark it solved: I tried to modify the formula to allow me to select several categories at once (4,5 and 7 for example), but i couldn't manage it (in my attempt, it just returned a blank). Do you think it is practical or feasible to do this, or would it make the formula too long / make the sheet volatile?

    If you don't thin that it is practical, I will go ahead and mark this solved. I really appreciate the help.

    Many thanks

    George

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    Im away till the morning. Ill do i then. What's the max no of categories you"ll want to select.

    Yea. I've lived in Killinchy for years, but am now back up in the big smoke... for now at least.

  13. #13
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Brilliant, that's amazing. It would be a maximum of 15 categories, but less would do if that is not practical.

    I'm out in the sticks in Fermanagh, but I lived in the big smoke for about 10 years.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    Lakeland is great. Bro in law lives near Kesh. Enniskillen's a grand wee town...

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    Here it is set up and tested for 3. I am assuming (hoping) that your categories are all numbers. Given the header in G4, I think I'm OK. To extend, just change the bit in red:

    =IFERROR(INDEX('All Purchases'!A:A,AGGREGATE(15,6,ROW('All Purchases'!$A$2:$A$1000)/(('All Purchases'!$A$2:$A$1000>=$B$2)*('All Purchases'!$A$2:$A$1000<=$D$2)*('All Purchases'!$B$2:$B$1000<>"")*(ISNUMBER(SEARCH(1/(1/$B$4:$D$4),'All Purchases'!$G$2:$G$1000)))),ROWS(A$7:A7))),"")
    In this setup the categories MUST be in a ROW, not a COLUMN...
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Hi Glenn,

    Yeah Fermanagh is nice, when it's not raining.

    Thank you very much again for this - it is excellent!

    One tiny glitch I found when trying it out was that if I put a 1 in the category box, it seems to pick up category 1 and also category 10 as well (because 10 also has a 1 in it). I tried it on my main spreadsheet and the same thing happens - a 1 will pick up 1 and 10, 11, 12, 15 etc. A 5 will pick up 5 and 15.

    As it is, I would have to only use it with a maximum of 9 categories. Do you think this aspect of it is fixable, to allow it to distinguish between double digit categories?

    Many thanks

    George

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    The whole place is a bit wet.... not just Fermanagh.

    No problem. Your thread got me thinking about a more generic way of doing this (for text and numeric ("OR" criteria, in columns and in rows). So I posted a thread of my own and got a great answer from a guy in Vietnam (Phuocam). So here it is, now included in your formula.

    I have added a wee tweak. As you choose category items to include in J1:J15 the numbers that you have chosen disappear from the remaining available choices. The workings for that are in DD Choices. Then a Named Range (CTRL-F3 to view/edit) called DD_List selectsd the available choices and Data Validation/List/DD_List ensures that only valid selections can be made.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    01-07-2018
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Array with fixed source range

    Glenn,

    Thank you so much for this, it really is great.

    I copied it over to my main spreadsheet, and it works a treat.

    I really couldn't have figured all this out on my own, so thanks again.

    You mentioned you had lived in Killinchy, and it just came back to me that my wife and I used to go to Balloo House when we lived in Belfast. Nice wee spot - if we were there now I would certainly owe you a few pints for this!

    Best of luck with everything!

    Kind regards

    George
    Last edited by nunez100; 12-18-2018 at 06:30 PM.

  19. #19
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Array with fixed source range

    You may know my son Stephen, who worked there up to about 12 mo ago. V tall, big drinka water. Short wiry curly hair.

    All of Central-East Belfast is now my local...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Replace a source list from a range with a source list from an array
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2018, 10:48 AM
  2. Replies: 5
    Last Post: 02-22-2018, 01:47 AM
  3. [SOLVED] SUM VLOOKUP Col No.s in array fixed to variable
    By JonnieB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2013, 06:51 AM
  4. HLOOKUP without any fixed array
    By leongkeat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-27-2008, 03:32 AM
  5. [SOLVED] Variable column to fixed array
    By asaylor in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-09-2006, 12:34 PM
  6. Replies: 0
    Last Post: 03-05-2005, 06:06 PM

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