DA Form 6

Status
Not open for further replies.

SavageMind

New Member
Joined
Jan 29, 2007
Messages
9
Hi all this is my first post.

I am creating a DA Form 6 wich is used to determine duty cycles. The first two colums A&B are for rank and name by row. the next 40 colums are to put numbers and symbols to determine who's turn it is. the first person will have a / then will count down from the number of names on the worksheet. so if there are 30 names, the first person will have / in colum C and will couunt down from 29 until it reaches 1 then it will have another / until it reaches the end of the 40 colums. The second name will have a 1 in colum C, a / in colum D and then it will count down. I would like to automate this document so it will autofill these cells, will allow exceptions and caculate for exceptions. The proper filing out of this document is covered in AR 220-45 and has an example wich can be googled. My Excel knowledge is limited any help would be great thanks.

SavageMind
 
I don't have the HTML addin on my excel here so I can't post the spreadsheet. Anyway here is what I have. With your duty roster template. Make sure cell D7 is the first cell of day 1 of the roster for the first man on your list. Row 6 is your list of dates starting at D6 and column D from 7 on is manually completed by you. Now paste the following code into a module.

Code:
Public Sub CreateRoster()
'Use manual entries in the first day of the roster to calculate the rest.

Dim intRowTotal As Integer, intColTotal As Integer, row As Integer, col As Integer
Dim MaxDay As Integer, ManualNum As Integer
Dim MyRange As Range

intpress = MsgBox("Is the first day of the Duty Roster (Column D) complete?", vbYesNo)
'Makes sure that day 1 is complete
If intpress = 7 Then
Exit Sub
Else
intRowTotal = ActiveSheet.Range("B7", ActiveSheet.Range("b65536").End(xlUp)).Count
intColTotal = ActiveSheet.Range("D6", ActiveSheet.Range("bZ6").End(xlToLeft)).Count
'Calculate number of people and number of days for the roster
For k = 1 To intColTotal - 1
'k tracks the number of days
col = 4 + k
'start on 2nd day
    For N = 1 To intRowTotal
    'N tracks each person
    If ActiveSheet.Cells(6 + N, col).Value = "" Then
        'Do this when the cell value is empty
        If ActiveSheet.Cells(6 + N, col - 1).Value = "D" Then
        ActiveSheet.Cells(6 + N, col).Value = 1
        'If had the duty day prior set to 1
        Else
            If Application.WorksheetFunction.IsNumber(ActiveSheet.Cells(6 + N, col - 1).Value) = True Then
            ActiveSheet.Cells(6 + N, col).Value = ActiveSheet.Cells(6 + N, col - 1).Value + 1
            'if prior day was a number add 1
            Else
                i = 1
                Do Until Application.WorksheetFunction.IsNumber(ActiveSheet.Cells(6 + N, col - i).Value) = True
                i = i + 1
                If col - i = 0 Then Exit Do
                'if prior day not a number then look back to next day prior
                Loop
                If col - i = 0 Then
                'if we reach o then prompt for the number of the person
                ManualNum = InputBox("Enter " & ActiveSheet.Cells(6 + N, 1).Value & " " & ActiveSheet.Cells(6 + N, 2).Value & " previous Roster Number?")
                ActiveSheet.Cells(6 + N, col).Value = ManualNum + 1
                Else
                'If number found add 1 to it
                ActiveSheet.Cells(6 + N, col).Value = ActiveSheet.Cells(6 + N, col - i).Value + 1
                End If
            End If
        End If
    Else
    GoTo skip
    'if the cell is filled skip it dont overright it
    End If
    Next N
    'once the entire column is filled in
    Set MyRange = ActiveSheet.Range(Cells(7, col), Cells(7 + intRowTotal, col))
    MaxDay = Application.WorksheetFunction.Max(MyRange)
    'find the largest number
    MaxDay = Application.WorksheetFunction.Match(MaxDay, MyRange, 0)
    ActiveSheet.Cells(6 + MaxDay, col).Value = "D"
    'replace largest number with "D"
skip:
 Next k
 'Do next day
End If
End Sub

Now go through the roster and put in any leave or absences. Save the spreadsheet and then run the macro CreateRoster... One thing if the first day of the roster has a guy on leave what number should he be when he comes off leave. It will prompt you for their previous number. Since this thread is getting quite long you may want to just send me a private message to work out the final details.

Let me know how close it is.
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Book1
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
6123456789101112131415161718192021222324252627282930
7123456789101112DPPPPD123456D12345
8234567D1234567D123456D1234
934567D1LLLLL2345678D123456
104567D12345678D123456D
11567D12345678D123456D1
1267D12345678D123456D12
137D12345678D123456D123
Sheet1
 
Upvote 0
It has a few bugs as you can see above, but I can try to work it a bit and post the code here.

When I first attempted this project a few years back, I had no idea about VBA or this forum. I am glad this was asked here, because I love reworking old failed projects :)

I think we should keep it here since there is more the 2 interested parties involved in this, and would be interesting to use this forum as a collaborative site. :)
 
Upvote 0
I have it completed, I think? If you would like to test it out Private Message me your email and I'll send you a file. Here is kind of what it looks like.
Duty Roster.xls
ABCDEFGHIJKLMN
3DUTYROSTERNATUREOFDUTY
4KitchenPolice
5GRADENAMEMonthDecember
6Day1234567891011
7SGTSmithD12345678910
8SGTJones11D123456789
9SGTJohnson1011D12345678
10SGTMerrick91011D1234567
11SGTSchroeder891011D123456
12SGTNoelLLLLLLLL345
13SGTSledge7891011D12345
14SGTBrownL67891011D123
15SGTWhite67891011D1234
16SGTBlack56789101112D12
17SPCHoustonS6S7S891011S12
18SPCJersey456789101112D1
19SPCJacksonEEE6789101112D
Sheet1
 
Upvote 0
Here is the corrected code I used to generate the roster above:

Code:
Public Sub CreateRoster()

'Use manual entries in the first day of the roster to calculate the rest.

Dim intRowTotal As Integer, intColTotal As Integer, row As Integer, col As Integer
Dim MaxDay As Integer, ManualNum As Integer
Dim MyRange As Range

intpress = MsgBox("Is the first day of the Duty Roster (Column D) complete?", vbYesNo)
'Makes sure that day 1 is complete
If intpress = 7 Then
Exit Sub
Else
intRowTotal = ActiveSheet.Range("B7", ActiveSheet.Range("b65536").End(xlUp)).Count
intColTotal = ActiveSheet.Range("D6", ActiveSheet.Range("bZ6").End(xlToLeft)).Count
'Calculate number of people and number of days for the roster
For k = 1 To intColTotal - 1
'k tracks the number of days
col = 4 + k
'start on 2nd day
    For n = 1 To intRowTotal
    'N tracks each person
    If ActiveSheet.Cells(6 + n, col).Value = "" Then
        'Do this when the cell value is empty
        If ActiveSheet.Cells(6 + n, col - 1).Value = "D" Then
        ActiveSheet.Cells(6 + n, col).Value = 1
        'If had the duty day prior set to 1
        Else
            If Application.WorksheetFunction.IsNumber(ActiveSheet.Cells(6 + n, col - 1).Value) = True Then
            ActiveSheet.Cells(6 + n, col).Value = ActiveSheet.Cells(6 + n, col - 1).Value + 1
            'if prior day was a number add 1
            Else
            If ActiveSheet.Cells(6 + n, col - 1).Value = "D" Then
            ActiveSheet.Cells(6 + n, col).Value = 1
            End If
            i = 1
                Do Until Application.WorksheetFunction.IsNumber(ActiveSheet.Cells(6 + n, col - i).Value) = True Or ActiveSheet.Cells(6 + n, col - i).Value = "D"
                i = i + 1
                If col - i = 0 Then Exit Do
                'if prior day not a number then look back to next day prior
                Loop
                If col - i = 0 Then
                'if we reach o then prompt for the number of the person
                ManualNum = InputBox("Enter " & ActiveSheet.Cells(6 + n, 1).Value & " " & ActiveSheet.Cells(6 + n, 2).Value & " previous Roster Number?")
                ActiveSheet.Cells(6 + n, col).Value = ManualNum + 1
                Else
                'If number found add 1 to it
                    If ActiveSheet.Cells(6 + n, col - i).Value = "D" Then
                    ActiveSheet.Cells(6 + n, col).Value = 1
                    Else
                    ActiveSheet.Cells(6 + n, col).Value = ActiveSheet.Cells(6 + n, col - i).Value + 1
                    End If
                End If
            End If
        End If
    Else
   
   
    End If
    Next n
    'once the entire column is filled in
    Set MyRange = ActiveSheet.Range(Cells(7, col), Cells(7 + intRowTotal, col))
    MaxDay = Application.WorksheetFunction.Max(MyRange)
    'find the largest number
    MaxDay = Application.WorksheetFunction.Match(MaxDay, MyRange, 0)
    ActiveSheet.Cells(6 + MaxDay, col).Value = "D"
    'replace largest number with "D"

 Next k
 'Do next day
End If
ActiveSheet.Range(Cells(5, 5), Cells(5, 43)).Value = ""
EndMonth = Application.WorksheetFunction.Choose(Month(Cells(4, 37)), "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
n = 43
Do Until ActiveSheet.Cells(6, n).Value = 1
n = n - 1
Loop
ActiveSheet.Cells(5, n).Value = EndMonth
End Sub
 
Upvote 0
Look Great I would Like to try it. I now have to figure out how to caculate weekend and holidays as a seperate sequence
 
Upvote 0
I have my sheet skipping weekends and any dates typed into my holiday list. Like in my example below the 23 is skipped because of turkey day and the 25 and 26 were skipped (weekend)
Holiday Duty Roster.xls
ABCDEFGHIJKLMNO
5GRADENAMEMonthNovember
6Day20212223242526272829301
7SGTSmith123456789
8SGTJones2345SSSSS67
9SGTJohnson34567891011
10SGTMerrickLLL5678910
11SGTSchroeder5678910111213
12SGTNoelD12345678
13SGTSledge789101112131415
14SGTBrown8910111213141516
Sheet1
 
Upvote 0
I know it has been awhile since you've posted your files dakota727, but would you happen to still have them? I was also trying to create something similar to this and am stuck on getting the weekday and weekend/holiday dates to be two separate number sequences. I was hoping that by looking at your work I could figure out where I was going wrong.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,602
Messages
6,173,294
Members
452,509
Latest member
CSHOCK

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top