+ Reply to Thread
Results 1 to 7 of 7

Auto-populate cells if other cells meet a criteria

  1. #1
    Registered User
    Join Date
    11-25-2017
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    4

    Auto-populate cells if other cells meet a criteria

    Hi! I'm a novice on excel trying to auto-populate some cells.

    I have a row with dates (going weekly) and I want to be able to return specific cells under these dates if today's date fall under the week displayed.

    Ex: I want to return the data in F9 to A11 and F11 to B11 since we are in the week of Oct 28 and there are items in the cells under it. Now if we move from the week of Oct 28 to Nov 4, I'd like the formula to retun what is in G9 to A11 and blank out B11, C11 and D11 since there is nothing there for that week.

    Please see attached example file. Thanks everyone for helping me out with this
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Auto-populate cells if other cells meet a criteria

    You have merged cells (e.g. F9/G9, H10/I10) but when we are looking at next week then G9 will be seen as empty, so you will have to un-merge those cells and repeat the entries. Then it would be relatively easy to retrieve the data in the layout you wish.

    Pete

  3. #3
    Registered User
    Join Date
    11-25-2017
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Auto-populate cells if other cells meet a criteria

    Quote Originally Posted by Pete_UK View Post
    You have merged cells (e.g. F9/G9, H10/I10) but when we are looking at next week then G9 will be seen as empty, so you will have to un-merge those cells and repeat the entries. Then it would be relatively easy to retrieve the data in the layout you wish.

    Pete
    Hi Pete,

    Thanks so much for taking a look at this! I've unmerged the cells. Where should I go from there?
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Auto-populate cells if other cells meet a criteria

    You can put this formula in A11:

    =IFERROR(INDEX($F$9:$R$12,MATCH(A$10,$E$9:$E$12,0),MATCH(TODAY(),$F$6:$R$6))&"","")

    and copy across to D11, and this similar formula in A16:

    =IFERROR(INDEX($F$14:$R$17,MATCH(A$15,$E$14:$E$17,0),MATCH(TODAY(),$F$6:$R$6))&"","")

    copied across to D16.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    11-25-2017
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Auto-populate cells if other cells meet a criteria

    Quote Originally Posted by Pete_UK View Post
    You can put this formula in A11:

    =IFERROR(INDEX($F$9:$R$12,MATCH(A$10,$E$9:$E$12,0),MATCH(TODAY(),$F$6:$R$6))&"","")

    and copy across to D11, and this similar formula in A16:

    =IFERROR(INDEX($F$14:$R$17,MATCH(A$15,$E$14:$E$17,0),MATCH(TODAY(),$F$6:$R$6))&"","")

    copied across to D16.

    Hope this helps.

    Pete
    Hi Pete,

    Thank you so much! This is amazing! If I'm looking for an explanation for how each of these functions work, is this the place to do it? New to this forum and don't want to break any rules but I'd like to learn more about how to use excel from experts like you if possible!

    Thanks again!
    Shirora

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Auto-populate cells if other cells meet a criteria

    The INDEX function can return the value from a particular cell within a 1-d or 2-d range. The general syntax is:

    =INDEX( range , row_number , column_number )

    It is often used in conjunction with the MATCH function, which has the ability to find where a search_cell exists within a 1-d range - its general syntax is:

    =MATCH( search_cell , range , type )

    where type determines if you are looking for an exact match (value of FALSE or 0 ) or an approximate match (value of TRUE or 1 or omitted).

    So the first formula is looking at the range F9:R12, though you might have to extend this by changing the R if you add more data to the right.

    The row from which we want to retrieve the data is given by the first MATCH function. This tries to find an exact match between cell A10 and the numbers in cells E9 to E12, although strictly speaking you could just use A$10 instead of the MATCH function here, as the numbers are the same as the row_number that we are looking for. The second MATCH function is trying to find an approximate match between TODAY() and the dates stored in the cells from F6 to R6. With an approximate match the function will return the relative column_number in that range where the values (i.e. the dates) are less than or equal to the search_value (i.e. TODAY() ). For this to work correctly, the values have to be sorted (as yours are). Those two values thus determine the cell where we want the data to be returned from.

    As the formula is copied across, the A$10 will change to B$10, then C$10, and so on across, but the other ranges will not change because all the cell references are anchored by having the $ symbol in front of them (called absolute addressing), so we are always trying to find data from the row in the main table determined by the headers on row 10. The other formula is very similar, but some of the ranges are changed to suit the lower table.

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Also, since you are relatively new to the forum (in terms of post-count), you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete
    Last edited by Pete_UK; 10-30-2019 at 12:42 PM.

  7. #7
    Registered User
    Join Date
    11-25-2017
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Auto-populate cells if other cells meet a criteria

    Quote Originally Posted by Pete_UK View Post
    The INDEX function can return the value from a particular cell within a 1-d or 2-d range. The general syntax is:

    =INDEX( range , row_number , column_number )

    It is often used in conjunction with the MATCH function, which has the ability to find where a search_cell exists within a 1-d range - its general syntax is:

    =MATCH( search_cell , range , type )

    where type determines if you are looking for an exact match (value of FALSE or 0 ) or an approximate match (value of TRUE or 1 or omitted).

    So the first formula is looking at the range F9:R12, though you might have to extend this by changing the R if you add more data to the right.

    The row from which we want to retrieve the data is given by the first MATCH function. This tries to find an exact match between cell A10 and the numbers in cells E9 to E12, although strictly speaking you could just use A$10 instead of the MATCH function here, as the numbers are the same as the row_number that we are looking for. The second MATCH function is trying to find an approximate match between TODAY() and the dates stored in the cells from F6 to R6. With an approximate match the function will return the relative column_number in that range where the values (i.e. the dates) are less than or equal to the search_value (i.e. TODAY() ). For this to work correctly, the values have to be sorted (as yours are). Those two values thus determine the cell where we want the data to be returned from.

    As the formula is copied across, the A$10 will change to B$10, then C$10, and so on across, but the other ranges will not change because all the cell references are anchored by having the $ symbol in front of them (called absolute addressing), so we are always trying to find data from the row in the main table determined by the headers on row 10. The other formula is very similar, but some of the ranges are changed to suit the lower table.

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Also, since you are relatively new to the forum (in terms of post-count), you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete
    Hi Pete,

    Thanks! You've been so helpful and this is great! I've closed the thread as suggested. Thanks for letting me know about the reputation ratings too!

    Sincerely,
    Shirora

+ 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] Auto Populate Cells Based on a Criteria
    By danallamas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2017, 08:06 PM
  2. [SOLVED] Macro to clear cells in range & move up if certain cells meet criteria
    By samder68 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2016, 10:52 PM
  3. [SOLVED] Formula to auto populate cells to match multiple tabs with certain criteria
    By rowena229 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-18-2015, 04:42 PM
  4. Geomean last 5 cells where adjacent cells meet certain criteria
    By thomasart23 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-06-2014, 05:03 PM
  5. Replies: 5
    Last Post: 05-18-2013, 07:49 PM
  6. Replies: 14
    Last Post: 04-19-2011, 02:22 PM
  7. Replies: 15
    Last Post: 02-19-2011, 12:40 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