+ Reply to Thread
Results 1 to 24 of 24

Move and shift data depending on time period

  1. #1
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Move and shift data depending on time period

    I have data in columns A to X, differentiated by their week commencing date which is housed in column A:
    Last week
    This week
    Next week
    2&3 weeks from this week

    I would like the excel file to always be thinking in terms of 'Today's date' when opened, and the sets of data to be dynamic. So say I was to open the spread sheet next monday (27/01/17) I would like:

    - Last week's data to drop off this list to Sheet 3 (Archive)
    - This week (as of now) to become last week and shift up
    - Next week (as of now) to become this week and shift up
    - Week 2 of weeks 2&3 from now to become next week and shift up

    and so on

    Can this be achieved using vba?

    Thanks

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Hi, welcome to the forum.
    Yes it can. but what do you want to do with the obsolete data?
    You can choose to juts hide these rows but also to delete them.
    You could also add a new worksheet and there just display those rows you want to say with formulas so that the original data stays intact.
    Like a view sheet
    I suggest a sample workbook with some dummy data would help give your explanation a picture.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Thanks for your reply.

    Ideally, when last weeks data becomes 2 weeks old, it then transfers to Sheet3 (Archive).
    Archive keeps data for a month, after this period the data starts to be deleted.

    Otherwise, I just wish for the rest of the data (parameters above) to be shifted depending upon the date.
    So if the spreadsheet was opened this morning, the data at the top would be week commencing 13/02/17 (last week)
    Data with 06/02/17 would have been moved to the archive tab (as it is now 2 weeks old). 20/02/17 data would have been shifted up from next week to current week, etc etc.

    More than happy to attach the workbook or even just a screengrab pic to help explain - how can I do this?

    Thanks!
    Last edited by AliGW; 02-22-2017 at 02:57 PM. Reason: Unnecessary quotation removed.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    A screen grab, no, you can attach a file, select Go Advanced when replying and then look for Manage attachments, then select the file and press Upload file then close window and submit reply, if you more tha one file you can slecet another onet and upload and again and then close window and submit reply.

    I can't promise you I have the solution but I'd like to take a look. Are you familiar with macros (specifically VBA code)? This because you will have to some maintenance yourself and should not become dependent of others.

  5. #5
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Unfortunately I seem to only get a white line when trying to upload an attachment - could be blocked by policy at workplace.
    I can upload the file when I am at home later today for you.

    Familiar at beginner level, yes. I have already added some vba functionality to the workbook.
    I will upload in around 6 hours time, unless there is another place to upload between now and then - thanks
    Last edited by AliGW; 02-22-2017 at 02:57 PM.

  6. #6
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Bizarre, still just getting a white line when clicking the attachment button, no pop up or field or anything - can anyone advise? Is it because I am a new member? Have tried two different computers and different web browsers...

  7. #7
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Doesn't appear that I can upload any attachments, nor on my work pc or personal pc, so I will have to do my best at explaining to you roughly how my workbook is set up.

    Essentially:
    - Sheet 1 has buttons to filter the data in sheet 2 (time period views I have mentioned above).
    - Sheet 2 contains the Data, as an example, in cells A2:X26...
    So A2:X6 is last week, A7:X11 is the current week, A12:X16 is next week, A17:X26 is the next 2&3 week view.
    - Sheet 3 is an Archive tab containing data from the week before last.

    Hope this helps paint the picture of our earlier conversations and what I am hoping to achieve.

    Many thanks.
    Last edited by AliGW; 02-22-2017 at 02:57 PM.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    It's strange that you cannot attach files. I've attach a quick-and-dirty instruction maybe it helps.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Thanks! I didn't even notice that link. I was using the attachments button above the text window and for some reason it is not working.
    Your method worked great, hopefully you can see the attachment now?

    Thanks!
    Attached Files Attached Files
    Last edited by AliGW; 02-22-2017 at 02:58 PM.

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Attachment seen and downloaded, I will check and see what I can do to help you

  11. #11
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Quote Originally Posted by Keebellah View Post
    Attachment seen and downloaded, I will check and see what I can do to help you
    Great, thanks. Just remembered I had a couple of hidden sheets in there that I forgot to take out. Feel free to delete these.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    If they contain data you do not wish to share you must delte the attachment from the post. If you cannot then ask a moderator.
    I shall repost it with my solution without the hidden sheets.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Question: Do you have a problem if two (hidden columns) are added before Column A.
    A will become C and X will become Z

  14. #14
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Quote Originally Posted by Keebellah View Post
    If they contain data you do not wish to share you must delte the attachment from the post. If you cannot then ask a moderator.
    I shall repost it with my solution without the hidden sheets.
    They do not contain any data that I do not wish to share - they were more test sheets and I didn't want you to be referencing say Sheet 3 in vba and wondering why Sheet 3 is in fact Sheet 4 due to hidden sheets etc.

    Quote Originally Posted by Keebellah View Post
    Question: Do you have a problem if two (hidden columns) are added before Column A.
    A will become C and X will become Z
    No problem at all.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Extra columns will not be needed.
    For straters code for the Raw Data sheet's VBA
    Please Login or Register  to view this content.
    Test and see, the macro is triggered when that sheet is activated.

  16. #16
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Firstly, many thanks for your time on this.
    Ok, so to test I changed the dates of the first few row's of data in Raw Data to the week before last. Clicked back on the tab and they were gone as expected and everything else shifted up - great

    However, they didn't seem to get moved to the Archive tab, but appear to have been hidden instead? The Archive tab still houses some test data I already had in there, but this wasn't added to like expected?

    I wish for the data to be shifted up so if we were to open this workbook next Monday, this current week (as of today) will become last week so will be at the top of "Raw Data"... the current Last Week stuff which is at the top of "Raw Data" right now, will move to Archive. Hope this makes sense?

    Many thanks.
    Last edited by AliGW; 02-22-2017 at 02:58 PM. Reason: Unnecessary quotation removed.

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    It does, the data for today's Last week is first hidden and all data that was previous week's last week isx then unhidden and moved to archive.
    That is how I wrote this.

    The first loop checks for older data (Hidden rows which are prvious weeks Last week and unhides them and copies them to Arcive, then the second Look removes these rows from Raw Data and the third loop hides Last week's data

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Here is my file and a PDF showing before and after
    All you have to do is modify the VBA code to say <= wkNow instead of < wkOld if you want to mode 06-02- to archive too
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Quote Originally Posted by Keebellah View Post
    It does, the data for today's Last week is first hidden and all data that was previous week's last week isx then unhidden and moved to archive.
    That is how I wrote this.

    The first loop checks for older data (Hidden rows which are prvious weeks Last week and unhides them and copies them to Arcive, then the second Look removes these rows from Raw Data and the third loop hides Last week's data
    This is great, thank you. Is there a way I can modify the code so that today's Last week is not hidden i.e. the third loop? It's key that it is included in the overall view, as they may need to review the previous week. I only wish for it to be moved to the Archive tab when it becomes previous week's last week, if that makes sense?

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    Remove the third loop.

  21. #21
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    Quote Originally Posted by Keebellah View Post
    Remove the third loop.
    Thanks. Have removed:
    Please Login or Register  to view this content.
    Which now seems to prevent the rows being hidden and instead they just go to archive - great

    I have a quick question:
    I did the following as you suggested:
    All you have to do is modify the VBA code to say <= wkNow instead of < wkOld if you want to mode 06-02- to archive too
    But it moved over the 13/02/2017 data too, which I would have expected to remain in the Raw Data tab as it is last week whereas 06/02/17 is the week before and therefore I would expect that to move to archive... but not both. Any ideas?

    Thank you

  22. #22
    Forum Contributor
    Join Date
    02-20-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    133

    Re: Move and shift data depending on time period

    May have solved it. Added an <= to wkOld instead of just = and think it has done the trick

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Move and shift data depending on time period

    True, good work see, it's not that difficult.
    VBA is just plain step by step instructions carried out one after another and if you read it like you a series of instructions you actually see what happens, that's all there is to it

  24. #24
    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,718

    Re: Move and shift data depending on time period

    JRC1 - I have tidied up the unnecessary quoting - please stop doing it unless crucial to your post. It rarely is, in fact.
    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.

+ 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. Time Related Data applied over time period
    By dooleygj in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-11-2014, 06:54 AM
  2. Finding first and last values in shift work data for an extended period
    By simon.young in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2014, 05:45 AM
  3. [SOLVED] Complicated:Calculate time period based on no. of units sold + fluctuations within period
    By omaha.crab in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2012, 03:04 AM
  4. Move data depending on criteria
    By fatpiggy123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2010, 08:35 PM
  5. Blocking cells depending of the time period
    By Statsman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-10-2008, 02:43 PM
  6. [SOLVED] Move data to new sheet depending on criteria
    By enna49 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 06:10 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