+ Reply to Thread
Results 1 to 17 of 17

Break Rota with VBA.

  1. #1
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Question Break Rota with VBA.

    Hi all,

    I need some help with an automatic break rota for work.

    Screenshot 2020-09-07 at 19.03.05.png

    The aim is to have the cells to the right of the shifts with blanks and 1s in them automatically be filled when the shift is selected. For instance, if I were to change Joe's shift to 10-19, I wish for the cells to automatically fill with the blanks and 1's along with the colour. (1 meaning they are currently working).

    I have searched a round and havent been able to find an exact solution to this. It would be probably have to involve a command button when all the names of the staff and their shifts have been entered, you hit the run button and it automatically fills the cells appropriatley on the day's rota for the hours they are working.

    FYI, this is an example image, the actual workbook is a lot prettier haha.

    I would be grateful if anyone could solve this issue for me!


  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    Post the pretty workbook.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Unfortunately I can't!

    My workplace computers are secure as we deal with sensitive information. Therefor we cannot email outside email addresses or share files to outside parties.

    We track the breaks for staff between the hours of 0700 and 0000 HRS. So anything to automate this process rather than going along each staff member's row filling in the blanks and 1's would be great.

    Sorry to be a pain!

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Break Rota with VBA.

    Quote Originally Posted by hyding View Post
    Sorry to be a pain!
    You are not being a pain, but if you don't provide a sample workbook, then in essence, you are asking somebody else to mock-up a workbook and then supply the answer.

    The folks on this forum are excellent at providing answers, but not many want to mock-up your sample.

    Note: take a quick read of the "yellow" banner.
    HTH
    Regards, Jeff

  5. #5
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13
    Quote Originally Posted by jeffreybrown View Post
    You are not being a pain, but if you don't provide a sample workbook, then in essence, you are asking somebody else to mock-up a workbook and then supply the answer.

    The folks on this forum are excellent at providing answers, but not many want to mock-up your sample.

    Note: take a quick read of the "yellow" banner.
    I am going to work shortly so I will grab the workbook from work and upload it within the next hour.

  6. #6
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    I have now attached the blank rota sheet .
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Anyone that can help?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    I'll try and look tomorrow. Someone else might have picked it up by then ...

  9. #9
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Quote Originally Posted by TMS View Post
    I'll try and look tomorrow. Someone else might have picked it up by then ...
    Great, thanks a lot mate

    One thing to note, on the blank workbook I provided in a previous comment, there will be another colum next to the first colum on the left (where the staff member's names will go).

    In this additional colum is where the shifts will be inputted.
    Last edited by hyding; 09-08-2020 at 06:11 PM. Reason: Clarifcation

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    Wondered about that. It would probably make life easier if the shift start and end values were in separate columns? Is that possible? Not necessarily a show stopper but it will make the formula complex ( I expect ).

    So the names are in column A, shifts in column B, and everything else starting in column C??

  11. #11
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Quote Originally Posted by TMS View Post
    Wondered about that. It would probably make life easier if the shift start and end values were in separate columns? Is that possible? Not necessarily a show stopper but it will make the formula complex ( I expect ).

    So the names are in column A, shifts in column B, and everything else starting in column C??
    That would be fine yes! Let's say Names in column A, shift start in B, shift end in C and then everything starting in D.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    Ok. And, for the sake of argument, start times, end times, and time slots ( column headers) will all be time values in the format "hh:mm".

    Goodnight

  13. #13
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Quote Originally Posted by TMS View Post
    Ok. And, for the sake of argument, start times, end times, and time slots ( column headers) will all be time values in the format "hh:mm".

    Goodnight
    Yes exactly

    Goodnight!

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    Here's a worked example based on your sample file.

    Please look at the Test Area at the bottom for the examples.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    03-10-2020
    Location
    London, England
    MS-Off Ver
    365 2018
    Posts
    13

    Re: Break Rota with VBA.

    Quote Originally Posted by TMS View Post
    Here's a worked example based on your sample file.

    Please look at the Test Area at the bottom for the examples.
    Looks good mate, for some reason when changing the shifts the code doesn't seem to be working? As in, it doesn't autofill in the test area.

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    There's no code. Just a formula in cell H50 copied down and across. Cells F50:G59 have Data Validation to select shift start or end at 15 minute intervals. Row 60 has totals (for the test area).

    In principle, this doesn't require VBA. It's possible to drop the formula into new rows using a Worksheet Change Event handler but, personally, I think that would be overkill.

    You could achieve much the same outcome by using a Structured Table. You'd have to get rid of the merged cells ... but I’d do that anyway and just double the height of each row.

    I'd also move the reference data elsewhere, for example, onto the second sheet that I added. Being realistic, I wouldn't have thought you'd want to print this and having it way over on the right isn't that convenient for referring to it.

    If you want a VBA solution, please clarify your requirements/expectations based on the updated example.

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,033

    Re: Break Rota with VBA.

    Just wondered if you found the solution proposed useful?

    Either way, you may want to provide some feedback and, if it was, mark the thread solved.

    Incidentally, please be aware that files that you upload often have a user name, or two, included. From that/those, anyone who is interested can Google your name and gather information about you and where you are employed (currently and in the past), where you live, where you went to school, and so on. You may want to edit the Author and any other details, particularly on company related files.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Excel Rota - Flagging when 6 shifts are set on rota in a row
    By Delta Foxtrot in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-21-2020, 05:55 AM
  2. Replies: 14
    Last Post: 05-23-2015, 06:26 AM
  3. Replies: 0
    Last Post: 04-07-2015, 11:39 PM
  4. Help with a rota
    By Jayblath in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 07:34 PM
  5. Rota
    By -Doubleoseven- in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 03-14-2011, 05:34 PM
  6. Vertical Page Break / Column Break
    By kmg2424 in forum Excel General
    Replies: 0
    Last Post: 07-27-2010, 08:10 AM
  7. Break cell into multiple lines by line break
    By Chia in forum Excel General
    Replies: 1
    Last Post: 08-20-2006, 01:40 AM

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