+ Reply to Thread
Results 1 to 29 of 29

Automatically shift columns based on start/end date

  1. #1
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Automatically shift columns based on start/end date

    Hello everyone,

    I am working on a project employee capacity-sheet, with several projects and the capacity for each month.
    I want the percentages (D2:M4) shifted automatically when I, let's say, change the end date to 2023-05.

    How do I achieve this? Thank you so much in advance!
    Attached Files Attached Files
    Last edited by rflee97; 05-13-2022 at 07:12 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Automatically shift columns based on start/end date

    Welcome to the forum.

    This will require VBA. Shall I move the thread for you?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Okay. Yes, please!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Automatically shift columns based on start/end date

    That's all done.

  5. #5
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Hey Rflee,

    How would you like the percentages shifted?
    I see that you have a percentage in D2:M4 and 3 empty cells under the first date and the last two dates

  6. #6
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Hi Carlmon,

    Thanks for your reply. So the percentages are now filled according to the two dates. So from column D (2022-06) through column M (2023-03).

    If I change the end date to 2023-05, the percentages should be filled from column D through column O. Additionally, if i change the start date to 2022-07, the percentages should start at column E.

  7. #7
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Perfect I understand what you're saying. I'll get you back a code in 10 minutes

  8. #8
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Here you are Rflee. If I helped you out, please consider adding rep. THX

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Apologies, I forgot to remove the percentages if the date is before or after the selected times (fixed in the code below) .... Also, looks like you're new to VBA.. consider googling "How to write a code in VBA" to get to the proper location to run this code.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Thank you so much!

    Will this also work if I add another project (Project B) underneath this one?

  11. #11
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    I could write a code that looks for a project in the left-most column and perform the same actions as above... attach an example workbook of that and I will get something for you.

    I'm leaving my job soon and will get back to you on Monday if I leave before I finish.

  12. #12
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    I updated my workbook in the original post. I added a second tab where all the projects would be and their start/end-dates.

    Thanks again and enjoy your weekend!

  13. #13
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Will your start and end dates be the same for both projects?

  14. #14
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    No, they will be different for every project.

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Automatically shift columns based on start/end date

    Why two different sheets...I would make use of 1 sheet...
    Change dates in Red Columns...Take note...No error trapping in as yet...
    Code in Sheet Module...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  16. #16
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Hi sinter, thanks a lot! That makes more sense, indeed.

    I forgot to mention, however: it should be possible to change the 100% capacity to, let's say, 80%. So it should be variable and the value should be manually adjustable.

    It that possible?

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Automatically shift columns based on start/end date

    Something like this perhaps...Code fires when % column is entered...
    Attached Files Attached Files

  18. #18
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Hi Rflee, Did you get this one resolved? I can write you something today if you still need help.

  19. #19
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Thanks sintek, this is exactly what I'm looking for!

  20. #20
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Hi carlmon, I got what I am looking for. Thanks to you too!

  21. #21
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Automatically shift columns based on start/end date

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

  22. #22
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Hi sintek, may I ask for your assistence one last time?

    I changed the year-month fields (YYYY-MM) from data type general to date, so they add up correctly, instead of going from 2022-12 to 2022-13.
    But now the VBA module does not seem to work anymore. Did I break the whole thing now?

    Also, is there an option to trigger the module with multiple actions? So not only if the '% Allocation' is entered, but also if the end date is changed?

    If you have any time, it would be highly appreciated!

  23. #23
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    I can take a look while he's offline, can you post the latest workbook?

  24. #24
    Registered User
    Join Date
    05-06-2022
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    20

    Re: Automatically shift columns based on start/end date

    Thank you! I updated the file in my original post on the top, should be called 'UTA'. Can you see it?

  25. #25
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    Yep, looking at it now!

  26. #26
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Automatically shift columns based on start/end date

    Yep...You broke it...lol
    You added an extra column and changed date formats to have two different formats available...
    This should solve...
    Please Login or Register  to view this content.

  27. #27
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    LOL I changed the offset from -3, -2 to -2, -1 and it also seemed to work.

  28. #28
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Automatically shift columns based on start/end date

    @ carlmon...Strange as the code would only fire if Col F changed...Not E as in original code...

  29. #29
    Valued Forum Contributor
    Join Date
    10-12-2021
    Location
    CT
    MS-Off Ver
    365
    Posts
    462

    Re: Automatically shift columns based on start/end date

    I changed this line:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    and it worked for me - but I also didn't finish checking that it was working entirely - it just had no errors.

+ 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: 1
    Last Post: 07-13-2019, 01:12 PM
  2. Shift annual costs forward based on new start date
    By Rachel K in forum Excel General
    Replies: 7
    Last Post: 05-27-2018, 02:43 PM
  3. Replies: 2
    Last Post: 08-25-2017, 03:46 AM
  4. [SOLVED] How to make automatic 'parallel shift' based on specific start date?
    By wintheranders in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-29-2016, 07:16 AM
  5. Replies: 5
    Last Post: 08-04-2014, 06:42 PM
  6. Automatically calculating shift start times
    By lukela85 in forum Excel General
    Replies: 3
    Last Post: 09-20-2013, 03:06 PM
  7. Replies: 0
    Last Post: 12-27-2005, 06:10 PM

Tags for this Thread

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