Sure I'd be glad to here is the whole thing.
Sub Button14_Click()
Dim need As Integer
Application.Calculation = xlManual
skillx = 9
timeStart = -1
For period = 1 To 12
timeStart = timeStart + 8
For skilly = 104 To 124
skillNam = Sheet236.Cells(skillx, skilly).Value
need = (Sheet236.Cells(period + 318, skilly - 97).Value - Sheet236.Cells(period + 304, skilly - 97).Value) * 4
If skillNam = "ENG" Then
Eng period, timeStart, skilly, need
ElseIf skillNam = "IND" Then
Ind period, timeStart, skilly, need
ElseIf skillNam = "MMS" Then
MMS period, timeStart, skilly, need
Else
OtherSkill period, timeStart, skilly, skillNam, need
End If
Next skilly
Next period
Application.ScreenUpdating = True
MsgBox "Finished"
Calculate
End Sub
Public Sub Eng(ByVal period As Integer, ByVal timeStart As Integer, ByVal skilly As Integer, ByVal need As Integer)
Dim counter As Integer
Dim did As Boolean
Dim n As Integer
With Sheet236
For x = 11 To 298
counter = 0
did = False
For n = 1 To timeStart
If .Cells(x, n).Value = "ENG" Then
did = True
End If
Next n
If .Cells(x, skilly).Value = "x" And did = False Then
For y = timeStart To timeStart + 7
'If Application.CountIf(.Cells(x, y) _
' .Offset(0, 1).Resize(1, 8), ".") = 8 _
'And .Cells(x, y).Value = "." _
'And counter < 1 _
'And need > 0 Then
'.Cells(x, y).Value = "ENG"
If WorksheetFunction.CountIf(.Cells(x, y).Resize(1, 8), ".") = 8 _
And counter < 8 _
And need > 0 Then _
.Cells(x, y).Value = "ENG"
'Cells(x, y).Resize(1, 8).Value = "ENG"
counter = counter + 1
need = need - 1
Next y
End If
Next x
End With
End Sub
Public Sub Ind(ByVal period As Integer, ByVal timeStart As Integer, ByVal skilly As Integer, ByVal need As Integer)
Dim counter As Integer
Dim did As Boolean
Dim n As Integer
With Sheet236
For x = 11 To 298
counter = 0
did = False
For n = 1 To timeStart
If .Cells(x, n).Value = "IND" Then
did = True
End If
Next n
If .Cells(x, skilly).Value = "x" And did = False Then
For y = timeStart To timeStart + 7
If .Cells(x, y).Value = "." _
And counter < 8 _
And need > 0 Then
.Cells(x, y).Value = "IND"
counter = counter + 1
need = need - 1
End If
Next y
End If
Next x
End With
End Sub
Public Sub OtherSkill(ByVal period As Integer, ByVal timeStart As Integer, ByVal skilly As Integer, ByVal skillNam As String, ByVal need As Integer)
With Sheet236
For x = 11 To 298
If .Cells(x, skilly).Value = "x" Then
For y = timeStart To timeStart + 7
If .Cells(x, y).Value = "." _
And need > 0 Then
.Cells(x, y).Value = skillNam
need = need - 1
End If
Next y
End If
Next x
End With
End Sub
Public Sub MMS(ByVal period As Integer, ByVal timeStart As Integer, ByVal skilly As Integer, ByVal need As Integer)
Dim counter As Integer
Dim did As Boolean
Dim n As Integer
With Sheet236
For x = 11 To 298
counter = 0
did = False
For n = 1 To timeStart
If .Cells(x, n).Value = "MMS" Then
did = True
End If
Next n
If .Cells(x, skilly).Value = "x" And did = False Then
For y = timeStart To timeStart + 7
If .Cells(x, y).Value = "." _
And .Cells(x + 4, y).Value = "." _
And counter > 8 _
And need > 0 Then
.Cells(x, y).Value = "MMS"
counter = counter + 1
need = need - 1
End If
Next y
End If
Next x
End With
End Sub
I am having a problem with one part of it though, and I'm not sure if you will get a full understanding of what I am trying to do, so I'll e-mail you a zip of the file if you provide your address.
The problem I'm having is that there are two codes must be in 8 cells at a time, no other combination. Other tasks have the ability to be replaced with the next code in priority order. But "ENG" and "Ind" can only be for 8 cells horizontally or just add "." and move on to the next row. Both ENG and IND can be repeated in an 8 hours shift. All of the other codes can, oh I almost forgot. MMS can only be 8 hours (34) cells at a time.
Thanks for taking the time to look at this for me. I'll ditch the progress meter, if we can get this thing working.