+ Reply to Thread
Results 1 to 7 of 7

Macro or Formula needed to summarize Daily Tasks into Weekly Schedule

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2015
    Location
    US
    MS-Off Ver
    2010
    Posts
    5

    Macro or Formula needed to summarize Daily Tasks into Weekly Schedule

    Forewarning: This is a fairly complicated problem; I'm not even sure it's possible, but I will defer to your higher knowledge and wisdom. Perhaps there is an easier solution that I am overlooking, so feel free to offer alternative suggestions as well.

    Duties & Schedule.xlsx

    I am building a schedule for work. Our managers plan out an employee's tasks ahead of time each day. That job is performed on the "Daily Duty Assignments" tab. My problem resides in the Schedule tab.

    What I need this spreadsheet to do is find the left-most cell containing text in an individual employee's row, and then take the time in the corresponding column and input it into the "Start" column on the Schedule tab. Then I need to do the same exact thing with the right most cell that contains text, and input that time into the "End" column.

    The whole idea is to avoid taking the time to create two separate schedules, which contain the same basic data. We use the Daily Duty tab format in our daily operations, but the Schedule tab format is used to post a bi-weekly employee schedule in the back room.

    I hope this is possible, and I really appreciate any help and feedback that I can get!
    Last edited by diablo00124; 02-05-2015 at 11:21 AM. Reason: Re title

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,642

    Re: Building a schedule - in over my head!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Help with an Index problem, automating a schedule

    Please comply with ProtonLeah's request so that I can give you your solution.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    02-04-2015
    Location
    US
    MS-Off Ver
    2010
    Posts
    5

    Re: Help building a schedule, pulling time from a separate sheet using IFTEXT

    I will retitle it, but I'm honestly not sure how to conscientious describe this problem in one sentence.

    Sorry for my poor communication.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Help building a schedule, pulling time from a separate sheet using IFTEXT

    "Macro or Formula needed to summarise Daily Tasks into Weekly Schedule"

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,642

    Re: Macro or Formula needed to summarize Daily Tasks into Weekly Schedule

    Option Explicit
    Option Base 1
    Sub transfer()
        Dim DAILY       As Worksheet, _
            SCHEDULE    As Worksheet, _
            WkNum       As Long, _
            DestColumn  As Long, _
            DOW         As Long, _
            StartHour   As Long, _
            StartTime   As String, _
            ScheduleRow As Variant, _
            ScheduleCol As Variant, _
            Endtime     As Variant, _
            WeekTotals  As Variant, _
            DayTotal    As Variant, _
            RowTotal    As Variant
            
        Set DAILY = Sheets("Daily Duty Assignments")
        Set SCHEDULE = Sheets("Schedule")
        
        WkNum = DAILY.Range("N1").Value
        
        Set ScheduleCol = SCHEDULE.Range("3:3").Find(WkNum, LookIn:=xlValues)
        
        'get the column number
        DestColumn = ScheduleCol.Column
        
        ' find the weeknumber on the schedule sheet and scroll it to the top left
        If ActiveSheet.Name = SCHEDULE.Name Then
            Range(ScheduleCol.Address).Activate
            Application.Goto ActiveCell.Offset(3, 0), True
            ActiveWindow.SmallScroll Up:=5
        End If
        
        'week totals are the columns at the end of each weekday table/range
        WeekTotals = Array("I4:I15", "N20:N31", "N36:N47", "N52:N63", "N68:N79", "O84:O95", "O100:O111")
        
        With DAILY
            For Each DayTotal In WeekTotals
                'set pointer to day of the current week (daily N1)
                DestColumn = ScheduleCol + DOW
                
                'check each cell in rowtotal
                For Each RowTotal In .Range(DayTotal)
        
                    If RowTotal > 0 Then
                        
                        'start at column C and move right while it is blank (not working)
                        For StartHour = 3 To RowTotal.Column - 1
                            If .Cells(RowTotal.Row, StartHour) <> "" Then
                            
                                'when none blank cell found then get the employee's row
                                Set ScheduleRow = SCHEDULE.Range("B:B").Find(.Cells(RowTotal.Row, "B").Value, LookIn:=xlValues)
                                ScheduleRow = ScheduleRow.Row
                                
                                'get the start time from row 2 of the current day table and remove the trailing " -"
                                StartTime = .Cells(.Range(DayTotal).Row - 1, StartHour).Value
                                StartTime = Left(StartTime, Len(StartTime) - 2)
                                
                                'the end time is the sum of start time and total hours worked.  If the sum is greater than
                                '12 then get the remainder (assumes p.m.)
                                
                                'convert string value to integer, calculate and return to string
                                Endtime = (CLng(Left(.Cells(.Range(DayTotal).Row - 1, StartHour + RowTotal - 1).Value, 2)) + 1) Mod 12
                                Endtime = Endtime & Right(.Cells(.Range(DayTotal).Row - 1, StartHour + RowTotal - 1).Value, 7)
                                Endtime = Left(Endtime, Len(Endtime) - 2)
                                
                                'write to schedule
                                SCHEDULE.Cells(ScheduleRow, DestColumn).Resize(columnsize:=2).Value = Array(StartTime, Endtime)
                                Exit For
                            End If
                        Next StartHour
                    End If 'rowtotal
                    
                Next RowTotal
                
                'since there are two columns per day (start/end)
                'increment the day pointer offset
                'note that DOW
                DOW = DOW + 2
                
            Next DayTotal
        End With    'daily
    End Sub
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro or Formula needed to summarize Daily Tasks into Weekly Schedule

    Try This Spreadshet:

    Run Macro I to populate the weekly schedule from the task list
    Attached Files Attached Files
    Last edited by mehmetcik; 02-08-2015 at 09:19 PM.

+ 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] Need Help building a schedule
    By gburwell88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-14-2012, 01:12 PM
  2. Duty Schedule i'm building, looking for advice
    By tlbliss in forum Excel General
    Replies: 1
    Last Post: 03-07-2011, 08:29 PM
  3. Building a duty schedule, not sure what to do now.
    By tlbliss in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2011, 08:29 PM
  4. trying to organize a building schedule!
    By hcubed in forum Excel General
    Replies: 1
    Last Post: 04-01-2008, 01:33 AM
  5. [SOLVED] Schedule building help please
    By Macmo in forum Excel General
    Replies: 0
    Last Post: 12-04-2005, 08:40 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