savethisid,
You can run this macro to add the "Reason" columns to each section in the "Only to be seen by Admin" sheet:
Sub InsertReasonCols()
Dim rngInsert As Range
Dim rngFound As Range
With Sheets("Only to be seen by Admin")
Set rngFound = .Range("E4", .Cells(4, Columns.Count)).Find("From", , , xlWhole)
If Not rngFound Is Nothing Then
Set rngInsert = rngFound
Do While Not rngFound Is Nothing
Set rngInsert = Union(rngInsert, rngFound)
Set rngFound = .Range("E4", .Cells(4, Columns.Count)).Find("From", rngFound, , xlWhole)
If Not Intersect(rngFound, rngInsert) Is Nothing Then Exit Do
Loop
rngInsert.EntireColumn.Insert
rngInsert.Offset(, -1).Value = "Reason"
End If
End With
End Sub
Here's a slightly updated version of the previous macro, to include the Reason for change from the Request Form sheet:
Sub btn_Submit_Click()
Dim wsReq As Worksheet 'Request worksheet (Request Form)
Dim wsSch As Worksheet 'Schedule worksheet (Only to be seen by Admin)
Dim rngFindName As Range
Dim rIndex As Long
Dim strName As String
Set wsReq = ActiveSheet
Set wsSch = Sheets("Only to be seen by Admin")
With wsReq
If Trim(.Range("C7").Value) = vbNullString Then
.Range("C7:D8").Select
MsgBox "No employee code provided.", , "Shift Request Error"
Exit Sub
End If
Set rngFindName = wsSch.Columns("C").Find(.Range("C7").Value, , , xlWhole)
If Not rngFindName Is Nothing Then
rIndex = rngFindName.Row
strName = Trim(.Range("I6").Value)
If strName = vbNullString Then strName = "(-)"
wsSch.Cells(rIndex, Columns.Count).End(xlToLeft).Offset(, 1).Resize(, 6).Value = _
Array(.Range("C10").Text, .Range("F10").Text, .Range("C16").Value, .Range("C19").Value, strName, .Range("C23").Value)
.Range("C4:E5,C7:D8,C10:D11,C13:D14,C16:D17,C19:D20,C23:L26,F10:G11,I6:K7,J10:K11,J14:K15").ClearContents
.Range("C4:E5").Select
Else
.Range("C7:D8").Select
MsgBox "Employee Code [" & .Range("C7").Value & "] not found.", , "Shift Request Error"
End If
End With
End Sub
Bookmarks