+ Reply to Thread
Results 1 to 7 of 7

Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

  1. #1
    Registered User
    Join Date
    05-04-2017
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    3

    Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Hello everyone,

    First post here. I need some assistance with writing a formula that will allow me to count text values within an array of cells, creating the array based on the a key cell being present in a specific column. This spreadsheet is actually built in Google Drive, but most of (if not all) of the Excel functions carry over. Hoping y'all can help me out, pretending that this is built in Excel.

    I have a calendar I built, listed by week. I want to be able to count the number of times a particular text value shows up in each week, based on the week. I want to be able to do 1, 2, or 3 week's worth of counting, and sum each week's counts together. This may be an odd use case, but I'm trying to build a slick meal planning tool for my wife so she can meal plan for our family. We're on a tight budget, so we're trying to make every dollar count. Here's a screenshot to help.

    Picture1.jpg

    You can see at the top of the sheet, three cells that allow me to select the Sunday that starts each week of the up to 3 weeks of meal planning. Below that, you'll see an example of what the week looks like with the weeks starting on Sunday, in column B. There are different meal options, controlled by data validation basically making them drop-down fields. Below this week are additional weeks, carrying on for an entire calendar year. Yes, we're doing this all for meal planning. I'm really good at over-engineering things and making them complicated :-)

    Basically, what I'm trying to do, logically, is query B4:B389 for the value in cell B2 and, if found, count the number of times the text value in a reference cell (the meal name, present in a different sheet) is present in an array where the upper left-most cell in the array is the cell containing the date of the Sunday starting the week.

    So, if I'm planning for the week of 4/30/2017, the formula would query B4:B389, find the value of 4/30/2017 in B124, create an array with B124 being the left-most upper cell in the array, and count the number of times the text value in the reference cell is present in this array, dynamically created based off of the date value of the Sunday. The array for this week would B124:H129.

    Then, add this count to the output of this same formula, just referencing C2, and referencing D2, creating the same dynamic row/column array, thus allowing for 1, 2, or 3 weeks of meal planning.

    Conceptually, I could do this by nesting 52 IF(DATEVALUE(COUNTIF functions (or something to that likeness, which I've done before) for each of the three date options (cells B2, C2, D2), but I'd then have 156 nested formula sets in 1 cell, for each meal name, and that seems rather clunky.

    Thanks in advance for the help!

    Cheers,

    Matt
    Attached Files Attached Files
    Last edited by mattsmit87; 05-05-2017 at 12:35 PM.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Cool Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Hi Matt- Welcome to ExcelForum! It would be a big help if you could attach a sample workbook to your post, pared down to essentials, so we can try things out. You'll probably get more responses by doing so. Just click Edit Post, then hit Go Advanced. Scroll down to Manage Attachments and click. Browse for your file and upload it. Thanks- Lee
    Last edited by leelnich; 05-04-2017 at 11:51 PM.

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Ok, I just took an extra 15 minutes of my life to re-create your workbook (just sayin'... ). Your .jpg showed cell E1 selected, so I put the following formula there, but you can move it anywhere on the same sheet as the weekly entries. You'll need to adjust the reference to your off-sheet menu item. (I used Sheet2! A1). All this is shown in the attached file. I hope you find it useful. - Lee
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ps. If Excel seems to want cell E1 to be a date, just change its number format to 'General'.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Attached Files Attached Files
    Last edited by leelnich; 05-05-2017 at 03:11 AM.

  4. #4
    Registered User
    Join Date
    05-04-2017
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    3

    Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Thanks leelnich. I just uploaded a demo file, but looks like you beat me to it. I'll try your formula and let you know if I encounter any issues.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Hey, got the demo. Here's the updated version. Bon appetit...

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Attached Files Attached Files
    Last edited by leelnich; 05-05-2017 at 04:35 PM.

  6. #6
    Registered User
    Join Date
    05-04-2017
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    3

    Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Working perfectly! Many thanks, Lee.

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Help - Dynamically Create an Array, Based on Key Cell, and Count Text within Array

    Happy to help, Matt. If you're satisfied with the solution, please got to Thread Tools up top and mark this thread SOLVED. Thanks-Lee

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

+ 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. Conditional Formatting Text based on array values of adjacent array.
    By Quasar82 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-27-2017, 09:54 AM
  2. [SOLVED] how can i make this array change the cell in a column based on a text array
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-25-2016, 09:44 AM
  3. [SOLVED] Create an array based on cell values
    By deadlyliquidxxx in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-26-2015, 09:41 AM
  4. Using Text From Cell to Help Create Lookup Array
    By Talofa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2013, 04:56 AM
  5. Create an array based off values in another array - exclude blanks
    By clifton1230 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2013, 05:35 PM
  6. [SOLVED] Create 1-col array identifying occurrence count in a 1-col array
    By empsall in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2013, 12:50 PM
  7. Replies: 7
    Last Post: 10-26-2012, 03:19 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