Sub ProjectSchedule()
'version 2.1
Dim Message As String, Title As String, Default As String
Dim myRange As range, rngTotal As range, c As range
Const strFind As String = "Samp-Mark"
Dim MyNewWbk As Workbook, inpWB As String, inpWS As String
Dim tempWB As Workbook
Dim fouNd As Boolean
Dim r As Long, z As Long, a As Long, b As Long
Dim numRows As Integer
Dim ans As Integer
Dim p As range
Application.DisplayAlerts = False
'Workbooks.Open Filename:="c:\book4.xls"
inpWB = ActiveWorkbook.Name
Worksheets("Schedule 2003"

.Activate
'Worksheets("Sheet1"

.Activate
Message = "Please select your date." ' Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "User input here" ' Set default.
On Error Resume Next
Set myRange = Application.InputBox(Message, Title, Default, , , , , 8)
On Error GoTo 0
If myRange Is Nothing Then
MsgBox "No date was entered, program will end!"
Exit Sub
End If
Application.ScreenUpdating = False
With Worksheets("Schedule 2003"

.range("A1:T1200"

'With Worksheets("Sheet1"

.range("A1:T1200"

'amend range to suit
Set c = .Find(What:=strFind, after:=range(myRange.Address), _
LookIn:=xlValues, SearchOrder:=xlByColumns) ', LookAt:=xlWhole
If Not c Is Nothing Then
'found it
Set rngTotal = .range(myRange, c.Offset(0, 3)) 'changed from (0,2)
rngTotal.Copy
End If
End With
Set MyNewWbk = Workbooks.Add
Sheets("Sheet1"

.Select
Sheets("Sheet1"

.Name = "WEEK"
MyNewWbk.Worksheets("WEEK"

.range("A1"

.PasteSpecial Paste:=xlValues
range("A1"

.Select
Selection.NumberFormat = "d-mmm"
'add a new workbook and copy the data to it
Application.CutCopyMode = False
Cells.Select
Cells.EntireColumn.AutoFit
range("A1"

.Select
Workbooks(inpWB).Close False
'Round to nearest number
Columns("D

"

.Select
Selection.NumberFormat = "0"
'Deletes empty rows
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
'takes out empty rows if no projects is inserted
Set myRange = ActiveSheet.range("A1:A6500"

numRows = Application.CountA(myRange)
For z = 1 To numRows
If Cells(z, 1) = "" Then
Rows(z).Delete
End If
Next z
Call Markers
End Sub
Sub endsub()
Exit Sub
End Sub
Sub Markers()
Dim p As range, rng As range, lLastRow As Long, ans As Variant
'Asking the right number of markers?
Application.ScreenUpdating = True
lLastRow = Cells(Cells.Rows.Count, "C"

.End(xlUp).Row
Set rng = range(Cells(1, "C"

, Cells(lLastRow, "D"

)
repl = MsgBox("Are the # of markers correct?", vbYesNo, "Project Status"

If repl = vbYes Then
Call Calculate
End If
If repl = vbNo Then
Call inputA
End If
End Sub
Sub inputA()
'Selecting the cell to change.
ans = Application.InputBox("Type the cell you wish to change. For example: C23.", Cell)
If ans = False Then
MsgBox ("Please type in a cell to change!"

, vbCritical, Warning
Call inputA
End If
If ans = "" Then
MsgBox ("Please type in a cell to change!"

, vbCritical, Warning
Call inputA
End If
inp = InputBox("Type in the new number.", Cell)
If inp = "" Then
MsgBox ("Please type in a number!"

, vbCritical, Warning
Call inputA
End If
range(ans).Value = inp
'Asking to change more cells.
quest = MsgBox("Do you have more markers to change?", vbYesNo, "Next step"

If quest = vbYes Then
Call inputA
End If
If quest = vbNo Then
Call Calculate
End If
End Sub
Sub Calculate()
'Continue with program
Const strFind As String = "Samp-Mark"
Application.ScreenUpdating = False
'Copy to temp workbook
Cells.Select
Selection.Copy
'Set tempWB = Workbooks.Add
Sheets("Sheet2"

.Select
Sheets("Sheet2"

.Name = "PLATES"
range("A1"

.Select
ActiveSheet.Paste
'Calculate the number of plates that are less then 384
Set myRange = ActiveSheet.range("A1:A6500"

numRows = Application.CountA(myRange)
For r = 3 To numRows
If Cells(r, 1) = strFind Then
Call Greaterthan384
End If
If Cells(r, 3) < 384 Then
If (Cells(r, 3)) <= 32 Then
Cells(r, 3) = 12
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
a = Cells(r, 5)
'b = Cells(r, 7)
Cells(r, 7).Select
ActiveCell.FormulaR1C1 = "=(RC[-2]/3)"
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
End If
If (Cells(r, 3)) > 33 Then
If Cells(r, 1) = strFind Then
Call Greaterthan384
End If
If (Cells(r, 3)) <= 48 Then
Cells(r, 3) = 8
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
a = Cells(r, 5)
Cells(r, 7).Select
ActiveCell = a / 6
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
'ActiveCell.FormulaR1C1 = "=RC[-2]/6"
End If
End If
If (Cells(r, 3)) > 49 Then
If Cells(r, 1) = strFind Then
Call Greaterthan384
End If
If (Cells(r, 3)) <= 96 Then
Cells(r, 3) = 4
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
Cells(r, 7).Select
ActiveCell.FormulaR1C1 = "=(RC[-2]/8)"
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
End If
End If
'If (Cells(r, 3)) > 97 Then
' If (Cells(r, 3)) < 143 Then
' Cells(r, 3) = 3
' Cells(r, 5).Select
' ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
' Cells(r, 7).Select
' ActiveCell.FormulaR1C1 = "=(RC[-2]/10)"
' End If
'End If
If (Cells(r, 3)) > 97 Then
If Cells(r, 1) = strFind Then
Call Greaterthan384
End If
If (Cells(r, 3)) <= 192 Then
Cells(r, 3) = 2
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
Cells(r, 7).Select
ActiveCell.FormulaR1C1 = "=(RC[-2]/10)"
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
End If
End If
If (Cells(r, 3)) > 193 Then
If Cells(r, 1) = strFind Then
Call Greaterthan384
End If
If (Cells(r, 3)) < 384 Then
Cells(r, 3) = 1
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
Cells(r, 7).Select
ActiveCell.FormulaR1C1 = "=(RC[-2]/4)"
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
End If
End If
End If
Next r
End Sub
Sub Greaterthan384()
Const strFind As String = "Samp-Mark"
Set myRange = ActiveSheet.range("A1:A6500"

numRows = Application.CountA(myRange)
For r = 3 To numRows
If Cells(r, 1) = strFind Then
Call FormateCells
End If
If (Cells(r, 3)) > 384 Then
ans = (Cells(r, 3)) / 384
Cells(r, 3) = ans
Cells(r, 5).Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Cells(r, 7).Select
ActiveCell.FormulaR1C1 = "=(RC[-2]/5)"
b = Cells(r, 7)
Selection.NumberFormat = "[hh]:mm"
ActiveCell = b / 24
End If
Next r
End Sub
Sub FormateCells()
Const strFind As String = "Samp-Mark"
'range("G3:G69"

.Select
'Columns("G:G"

.Select
'Application.CutCopyMode = False
'Selection.Copy
'range("H1"

.Select
'Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
' False, Transpose:=False
'Columns("G:G"

.Select
'Application.CutCopyMode = False
'Selection.Delete Shift:=xlToLeft
range("E3:E69"

.Select
Columns("E:E"

.Select
Application.CutCopyMode = False
Selection.Copy
range("F1"

.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("E:E"

.Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Columns("F:F"

.Select
Selection.Insert Shift:=xlToRight
'Round up formula for pcr plates
Set myRange = ActiveSheet.range("A1:A6500"

numRows = Application.CountA(myRange)
For r = 3 To numRows
If Cells(r, 5) > 0.01 Then
Cells(r, 6).Select
ActiveCell.FormulaR1C1 = "=ROUNDUP(RC[-1],0.1)"
End If
Next r
'Clean up the round up numbers
Columns("G:G"

.Select
Selection.Insert Shift:=xlToRight
Columns("F:F"

.Select
Selection.Copy
range("G1"

.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("E:F"

.Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
For r = 3 To numRows
If (Cells(r, 5)) < 1 Then
Cells(r, 5) = 1
End If
If Cells(r, 1) = strFind Then
Call Finish
End If
Next r
End Sub
Sub Finish()
Const strFind As String = "Samp-Mark"
range("a1"

.Select
Set myRange = ActiveSheet.range("A1:A650"

numRows = Application.CountA(myRange)
For r = 1 To numRows
fouNd = False
If Cells(r, 1) = strFind Then
fouNd = True
Cells(r, 5) = 0
Cells(r, 3) = 0
Cells(r, 6) = 0
'Cells(r, 6) = Selection.NumberFormat = "0.0"
'Cells(r, 6) = Selection.ClearContents
End If
Next r
range("I1"

.Select
ActiveCell.FormulaR1C1 = "=SUM(R[2]C[-3]:R[68]C[-3])"
range("F1"

.Select
ActiveCell.FormulaR1C1 = "=SUM(R[2]C[-1]:R[40]C[-1])"
range("E1"

.Select
ActiveCell.FormulaR1C1 = "1"
range("F1"

.Select
Application.CutCopyMode = False
Selection.Copy
range("F2"

.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "0"
range("I1"

.Select
Application.CutCopyMode = False
Selection.Copy
range("I2"

.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "[hh]:mm"
For r = 1 To numRows
fouNd = False
If Cells(r, 1) = strFind Then
fouNd = True
Cells(r, 5) = Cells(2, 6)
Cells(r, 6) = Cells(2, 9)
Cells(r, 6).Select
Selection.NumberFormat = "[hh]:mm"
Cells(r, 5).Select
Selection.NumberFormat = "0.0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Cells(r, 6).Select
'Selection.NumberFormat = "0.0"
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Cells(2, 9).Select
'Selection.NumberFormat = "0.0"
Cells(2, 5) = Cells(r, 6)
Cells(2, 5).Select
Selection.NumberFormat = "[hh]:mm"
'Selection.NumberFormat = "0.0"
End If
Next r
range("I1:I2:F1:F2"

.Select
Selection.Delete Shift:=xlToLeft
range("E1:E200"

.Select
Application.CutCopyMode = False
Selection.Copy
range("A1"

.Select
Worksheets("WEEK"

.Activate
range("E1"

.Select
ActiveSheet.Paste
'Worksheets("Sheet2"

.Activate
'Columns("A:J"

.Select
'Selection.Delete Shift:=xlToLeft
range("A1"

.Select
Worksheets("WEEK"

.Activate
Columns("D:E"

.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
'Highlighting the number of pcr plates
For r = 1 To numRows
If Cells(r, 1) = strFind Then
Cells(r, 5).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End If
Next r
'Format the time.
range("G2"

.Select
range("H2"

.Select
'ActiveCell.FormulaR1C1 = _
' "=INT(RC[-3])& "" hrs ""& ROUND((RC[-3]-INT(RC[-3]))*60,0)& "" min"""
'range("H2"

.Select
'Selection.Copy
'range("H3"

.Select
'Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
' False, Transpose:=False
'Application.CutCopyMode = False
'Selection.Copy
'range("E2"

.Select
'ActiveSheet.Paste
'Columns("G:H"

.Select
'Selection.ClearContents
'Selection.Interior.ColorIndex = xlNone
'Columns("E:E"

.Select
'Columns("E:E"

.EntireColumn.AutoFit
range("E2"

.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
range("A1"

.Select
Worksheets("PLATES"

.Activate
range("E2"

.Select
Selection.Delete Shift:=xlToLeft
Worksheets("WEEK"

.Activate
'copy information from sheet 1 to sheet 2
Sheets("WEEK"

.Select
Columns("A

"

.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("PLATES"

.Select
Columns("A

"

.Select
ActiveSheet.Paste
'centering column f
Columns("E:F"

.Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
range("A1"

.Select
Worksheets("WEEK"

.Activate
range("A1"

.Select
ActiveWindow.SelectedSheets.PrintPreview
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End Sub