Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SubWayScheduleFix()
- 'All the columns and Rows we want to delete
- Range("D:D,G:G,J:J,M:M,P:P,S:S,V:V,X:X").EntireColumn.Delete
- Rows(2).Delete
- ' Remove any style that may get carried over from the site
- With Range("A1:Q30")
- .ClearFormats
- .UnMerge
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- 'Make Adjustments
- 'Column Width & Row Height
- With Columns("A")
- .ColumnWidth = 25
- .RowHeight = 18 'This will change the entire sheets' rows height.
- 'Align right and leave a gap between cell wall and content
- .IndentLevel = 1 '0 Disables
- .HorizontalAlignment = xlRight 'Options xlLeft, xlRight, xlCenter
- End With
- Range("B1:Q1").ColumnWidth = 11
- 'Schedule Week Commencing
- With Range("A1:H1")
- .Merge
- .Font.Size = 13
- .Font.Bold = True
- .RowHeight = 22
- .IndentLevel = 1 '0 Disables
- .HorizontalAlignment = xlLeft 'Options xlLeft, xlRight, xlCenter
- End With
- 'Merge Cells
- Range("B2:C2,D2:E2,F2:G2,H2:I2,J2:K2,L2:M2,N2:O2").Merge 'Dates
- Range("B3:C3,D3:E3,F3:G3,H3:I3,J3:K3,L3:M3,N3:O3").Merge 'Days
- Range("B21:C21,D21:E21,F21:G21,H21:I21,J21:K21,L21:M21,N21:O21,P2:P4").Merge 'Total Hours
- Dim i As Integer, j As Integer
- For i = 5 To 20 Step 2 'Loop through and merge cells within the shift range
- j = i + 1
- Range("B" & i & ":B" & j & ", C" & i & ":C" & j & ", D" & i & ":D" & j & ", E" & i & ":E" & j & ", F" & i & ":F" & j).Merge
- Range("G" & i & ":G" & j & ", H" & i & ":H" & j & ", I" & i & ":I" & j & ", J" & i & ":J" & j & ", K" & i & ":K" & j).Merge
- Range("L" & i & ":L" & j & ", M" & i & ":M" & j & ", N" & i & ":N" & j & ", O" & i & ":O" & j & ", P" & i & ":P" & j).Merge
- Next i
- 'Time to Style
- 'Cell Format cells for date and shift times, this used the same code found in "Format Cells" within excel.
- Range("B2:N2").NumberFormat = "dd-mm-yyyy"
- Range("B5:O20").NumberFormat = "hh:mm AM/PM"
- 'MainColor
- Range("A4:P4,A21:P21").Interior.Color = RGB(231, 230, 230)
- 'Color 1 - Odd Rows
- For i = 5 To 20 Step 4
- j = i + 1
- Range("A" & i & ":P" & j).Interior.Color = RGB(255, 255, 255)
- Next i
- 'Color 2 - Even Rows
- For i = 7 To 20 Step 4
- j = i + 1
- Range("A" & i & ":P" & j).Interior.Color = RGB(242, 242, 242)
- Next i
- 'Borders
- 'Shift Area
- With Range("B2:P21")
- With .Borders
- .LineStyle = xlContinuous
- .Weight = xlThin
- End With
- End With
- 'Shift area Thick Borders
- For i = 2 To 21
- With Range("D" & i & ", F" & i & ", H" & i & ", J" & i & ", L" & i & ", N" & i & ", P" & i).Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .Weight = xlMedium
- End With
- Next i
- 'Employee Area
- For i = 5 To 20 Step 4
- j = i + 1
- Range("A" & i & ":A" & j).BorderAround LineStyle:=xlContinuous, Weight:=xlThin
- Next i
- 'Employee, Total Hours Column A Cells
- With Range("A4,A21")
- With .Borders
- .LineStyle = xlContinuous
- .Weight = xlThin
- End With
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement