+ Reply to Thread
Results 1 to 25 of 25

Populate Column D if Condition is Met

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Populate Column D if Condition is Met

    Looking for formula (non-array preferred) to look in F2:H36 and populate D2:D827 (desired output)if condition is met. To populate D2:D827, the condition to use is in B2 (B2=25).

    Condition: In B2, Total Sales value is 25 (B2=25). Total Sales value (condition in B2) is manually entered. For the example in this sample file, 25 is manually entered in B2.

    To populate D2:D827, the formula will look into column H for week 1 and return all week 1 dates 25 times (condition in B2 =25). For week 2 dates, the formula will look into column H and and return all week 2 dates 25 times (condition in B2 =25) right where week 1 dates ends and continue this process until the last week is populated.

    See sample file.

    Thanks.
    Attached Files Attached Files
    Last edited by bjnockle; 07-17-2021 at 05:05 PM.

  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,794

    Re: Populate Column D if Condition is Met

    Do you need to have the seven dates for week1 populated in sequence 25 times, or could you have the first date (27/12/2020) populated on the first 25 rows, then the next date in the next 25 rows, and so on?

    Pete

  3. #3
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Pete_UK: Do you need to have the seven dates for week1 populated in sequence 25 times. Yes, I need to have the seven dates for week1 populated in sequence 25 times and then the next seven dates for week 2 populated in sequence 25 times and so on. Thanks

  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,794

    Re: Populate Column D if Condition is Met

    You can use this formula in cell D2 (actually, I put it in E2 for comparison with your results):

    =INDEX(F:F,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)

    Then copy it down as far as you need to. If you have 5 weeks of 7 dates and you want to repeat them 25 times, this will mean that you need 5 * 7 * 25 cells (i.e. 875), so copy the formula down to row 876 (as it starts in row 2). Your list seems to have gone a bit awry.

    If the number in B1 might vary and you want blanks to be returned once all the data has been reproduced, then you could amend the formula to this:

    =IFERROR(1/(1/INDEX(F:F,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)),"")

    and then you can copy the formula down as far as you like.

    Hope this helps.

    Pete

  5. #5
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Pete_UK: The proposed formula works like a charm. Please assist with a formula to have seven dates for week1 populate Week1, Week2, Week3 and so on in sequence 25 times in column C. See sample file. Thanks a lot.
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Populate Column D if Condition is Met

    Please try at
    C2
    ="week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1

    D2
    =MOD(ROWS(D$2:D2)-1,7)+INT((ROWS(D$2:D2)-1)/7/$B$1)*7+$F$2
    Attached Files Attached Files

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

    Re: Populate Column D if Condition is Met

    Quote Originally Posted by bjnockle View Post
    ... Please assist with a formula to have seven dates for week1 populate Week1, Week2, Week3 and so on ...
    Bo_Ry beat me to it, though you might like to amend his formula in C2 to this:

    =IF(D2="","","week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1)

    then you can copy that down as far as you like and get blanks beyond the final value.

    Hope this helps.

    Pete

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

    Re: Populate Column D if Condition is Met

    By the way, 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.

    You might also 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

  9. #9
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Pete_UK: Outstanding solution. Thanks a lot.

  10. #10
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Outstanding solution, Bo_Ry.

  11. #11
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Pete_UK: This proposed formula (=IF(D2="","","week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1) ) works for column F2:F36 (month = Jan). Would like the formula adjusted to repeat week 1, week 2, week 3, week 4....... for the month of Feb (month in column I), same for Mar and so on. Desired outcome in column C. See sample file.

    Adjustment needed:
    I adjusted/modified your proposed formula =IFERROR(1/(1/INDEX(F:F,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)),"") to =IFERROR(1/(1/INDEX($F$2:$F$92,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)),""). The one I modified/adjusted is not pulling correctly (in column J).

    Please assist in fixing this formula in column J to pull exactly like your proposed formula in column D (column D formula working perfectly). See attached file.

    Thanks.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    Guessing ..

    in J2

    =IFERROR(1/(1/INDEX($F$36:$F$10000,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)),"")

    in K2

    =IFERROR(1/(1/INDEX($F$64:$F$10000,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)),"")

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

    Re: Populate Column D if Condition is Met

    It is easier just to look it up from column H. Put this formula in C2:

    =INDEX(H:H,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)&""

    then copy down as far as you like.

    Hope this helps.

    Pete

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

    Re: Populate Column D if Condition is Met

    Please note that in your formula in J2 you have changed the range so that it starts from the second cell - consequently, you will need +1 rather than +2 towards the end of the formula.

    Hope this helps.

    Pete

  15. #15
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    Pete_UK: It is easier just to look it up from column H. Column H is an example of the desired outcome I am looking for in column C. I manually entered the data in column H as example of what the desired outcome should be in column C. The proposed INDEX(H:H,INT((ROWS($1:1)-1)/($B$1*7))*7 + MOD(ROWS($1:1)-1,7)+2)&"" is looking into column H instead of D. The first proposed formula =IF(D2="","","week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1) needs tweaking to address the issue. Please help fix.
    Last edited by bjnockle; 07-30-2021 at 09:53 AM.

  16. #16
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    Did you look at post #12?

  17. #17
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    JohnTopley:Did you look at post #12?. I did look at post 12. Proposed answer in post 12 is not the correct solution. The solution I am looking for in column C will need to build on Pete_UK proposed formula =IF(D2="","","week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1). Thanks.

  18. #18
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    Formula in C2 is CONSTANT and simply lists repetitive number of "Week n" .(Date independent)

    The formula in D is Date dependent.

    in F2

    31/01/2021

    if F3=F2+1

    Copy down
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    JohnTopley: Column F is my sample data. The only column needing formula is column C. Please see attached

    Pete_UK: This proposed formula (=IF(D2="","","week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1) ) works for column F2:F36 (month = Jan). Would like the formula adjusted to repeat week 1, week 2, week 3, week 4....... for the month of Feb (month in column I), same for Mar and so on. Desired outcome in column C. See sample file.

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    Why are you reluctant to use column H as proposed by Pete? For starters you would have to provide the starting date of "Week 1" for each month { [and perhaps how many weeks in that month (the 5 4,4)

    As the data is already calculated why not use it? Treat column H as "helper" column and keep things simple.

    Based on using H

    in C2 and copied down

    =INDEX($H:$H,MATCH($D2,$F:$F,1))

    Just as F3 could be

    =F2+1

    and copied down

  21. #21
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    JohnTopley: Your proposed formula should look into E2:E2276 and return week 1, week 2, week 3, and so on and not column H. I have deleted column H to eliminate any confusion. The initial formula proposed by Bo_Ry Please try at
    C2
    ="week "&INT((ROWS(D$2:D2)-1)/7/$B$1)+1 works except that the formula is not repeating the week numbers as desired. See attached sample file.

    Thanks

  22. #22
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    I am not going to waste any more of my time when you take such an attitude re using the former column H as a helper column. I know why the formula does not work .....

  23. #23
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    JohnTopley: I apologize if you feel I take such an attitude. I have not taken an attitude. I was only trying to point out that I manually entered column H to show exactly what the proposed formula should be returning. Hopefully this help clear things up. Thanks.

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,308

    Re: Populate Column D if Condition is Met

    That is not the issue. There was no need to remove column H when it is quite a complex formula to work out where the weeks and start and end for a given month

    You had a solution which was a few minutes of your time and you expect us to spend much more of our time for what benefit???

    If the column H had been derived by formula (as a helper) you would probably have accepted it (??) ! And that is the best solution anyway so we end up where we started.

    Q.E.D

    See attached
    Last edited by JohnTopley; 07-30-2021 at 02:19 PM.

  25. #25
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Populate Column D if Condition is Met

    JohnTopley: Oustanding solution. Thanks a lot for the time spent on this and the understanding. Appreciate, JohnTopley.

+ 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. populate cell if condition is met
    By shaunsheep2345 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2020, 03:34 PM
  2. How to populate the column 3 under this condition??
    By raghuprabhu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2019, 08:46 AM
  3. [SOLVED] Insert column and populate data based on condition
    By tikistat in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-09-2017, 12:51 PM
  4. Populate one column based the condition of two other columns
    By warriorpoet7176 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-18-2014, 01:22 AM
  5. Populate 2-column data to multiple columns based on one condition
    By hcyeap in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-26-2013, 10:42 AM
  6. Select worksheet based on condition & populate cell based on condition
    By beth1069 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2011, 01:27 PM
  7. Populate based on a Condition
    By RallyFun in forum Excel General
    Replies: 5
    Last Post: 11-11-2011, 03:48 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