+ Reply to Thread
Results 1 to 20 of 20

populate cells based on a start year and cycle

  1. #1
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    populate cells based on a start year and cycle

    Please see attached file. I'm trying to take the cost from Column D to populate across columns H:AU based on the CYCLE YEARS and DUE IN YEAR listed in Columns E and F. Your help greatly appreciated.


    Regards,
    Seattlite
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Thank you Mumps 1. The code worked, but it looks like it's designed only for Row 6 and I'm looking for a solution to populate data for any row within the UninflatedComponentCosts arrary. Any additional thoughts on how to accomplish that?
    Last edited by jeffreybrown; 10-01-2020 at 03:55 PM. Reason: Please don't use full quotes!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Will each row have the same CYCLE YEARS and DUE IN YEAR? For example, row 6 has 5 and 4 respectively for CYCLE YEARS and DUE IN YEAR. Will all the rows below also have 5 and 4?

  5. #5
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Quote Originally Posted by Mumps1 View Post
    Will each row have the same CYCLE YEARS and DUE IN YEAR? For example, row 6 has 5 and 4 respectively for CYCLE YEARS and DUE IN YEAR. Will all the rows below also have 5 and 4?
    Each row will have a unique COST, CYCLE YEARS and DUE IN YEAR, so the solution will need to evaluate columns D, E and F for each row to populate the array appropriately.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Try:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Thanks again Mumps1. This time it appears that the first two rows are properly populated, but nothing beyond that. I've uploaded the macro-enabled workbook.
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Try:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Thank you! I ran it once and it worked!

    I added a random row further down the sheet and ran it again which forced me to kill the Excel process on my computer because it was stuck in an endless loop. Not sure what caused that...? Is there a way to get it to stop trying when it reaches what should be the end of the array area (which could have more rows inserted)?

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    The macro is designed to stop when it reaches the last Cost Value in column D. Are there any blank cells between the first Cost Value in column D and the last Cost Value in column D?

  11. #11
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Quote Originally Posted by Mumps1 View Post
    The macro is designed to stop when it reaches the last Cost Value in column D. Are there any blank cells between the first Cost Value in column D and the last Cost Value in column D?
    Ah I see. I did randomly populate a few rows and left some blank between the first set of values in D/E/F. That's what caused the "endless loop." Admittedly, the worksheet is not designed to be used that way. I'll add some instructions not to leave any rows blank. Great solution. Thanks again!

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    This version will ignore the blank cells.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Ah perfect! A very elegant solution.

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Glad to help.

  15. #15
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Hello again Mumps1. I previously neglected to add the individual component cost summaries to the right of the UninflatedComponentCosts arrary in columns AW and AX (see updated attached file). When I added these this and then ran the macro, the macro wiped out the formulas in these two new columns. Is there a way to limit the macro to stop at column AU?
    Attached Files Attached Files

  16. #16
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Try:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    Thanks again Mumps1. I seem to have still encountered an overwrite scenario where the macro looks beyond column AU (the end of the array for disseminating values) in certain situations. Any thoughts? Example attached with cells highlighted in red where values were written beyond the end of the UninflatedComponentCosts arrary.
    Attached Files Attached Files

  18. #18
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    Hopefully, this will solve the problem. I didn't realize that you would be adding columns of data to the right.
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    08-17-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: populate cells based on a start year and cycle

    My bad. I added a new column before the array and it threw everything off. I decided to just remove it and used your new code. Everything's great now. Thanks again
    Last edited by Seattlites; 10-06-2020 at 11:28 AM.

  20. #20
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: populate cells based on a start year and cycle

    My pleasure.

+ 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. Replies: 4
    Last Post: 01-11-2020, 02:38 PM
  2. Formula to populate cells based on Start and Finish dates.
    By Motox in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-15-2019, 11:53 PM
  3. Replies: 2
    Last Post: 08-25-2017, 03:46 AM
  4. Replies: 22
    Last Post: 03-16-2017, 09:42 PM
  5. Macro to copy rows and populate month/year based on start date?
    By ekwacillin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2016, 03:35 PM
  6. Replies: 5
    Last Post: 08-04-2014, 06:42 PM
  7. [SOLVED] Creating a formula to populate range of cells between dates based on start and end dates
    By Rainmain82 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-18-2014, 07:55 AM

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