Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub SubWayScheduleFix()
  2.    
  3.     'All the columns and Rows we want to delete
  4.    Range("D:D,G:G,J:J,M:M,P:P,S:S,V:V,X:X").EntireColumn.Delete
  5.     Rows(2).Delete
  6.    
  7.     ' Remove any style that may get carried over from the site
  8.    With Range("A1:Q30")
  9.         .ClearFormats
  10.         .UnMerge
  11.         .HorizontalAlignment = xlCenter
  12.         .VerticalAlignment = xlCenter
  13.     End With
  14.    
  15.     'Make Adjustments
  16.    'Column Width & Row Height
  17.    With Columns("A")
  18.         .ColumnWidth = 25
  19.         .RowHeight = 18 'This will change the entire sheets' rows height.
  20.        
  21.         'Align right and leave a gap between cell wall and content
  22.        .IndentLevel = 1 '0 Disables
  23.        .HorizontalAlignment = xlRight 'Options xlLeft, xlRight, xlCenter
  24.    End With
  25.     Range("B1:Q1").ColumnWidth = 11
  26.    
  27.     'Schedule Week Commencing
  28.    With Range("A1:H1")
  29.         .Merge
  30.        
  31.         .Font.Size = 13
  32.         .Font.Bold = True
  33.        
  34.         .RowHeight = 22
  35.         .IndentLevel = 1 '0 Disables
  36.        .HorizontalAlignment = xlLeft 'Options xlLeft, xlRight, xlCenter
  37.    End With
  38.    
  39.  
  40.     'Merge Cells
  41.    Range("B2:C2,D2:E2,F2:G2,H2:I2,J2:K2,L2:M2,N2:O2").Merge 'Dates
  42.    Range("B3:C3,D3:E3,F3:G3,H3:I3,J3:K3,L3:M3,N3:O3").Merge 'Days
  43.    Range("B21:C21,D21:E21,F21:G21,H21:I21,J21:K21,L21:M21,N21:O21,P2:P4").Merge 'Total Hours
  44.    
  45.    
  46.     Dim i As Integer, j As Integer
  47.     For i = 5 To 20 Step 2 'Loop through and merge cells within the shift range
  48.        j = i + 1
  49.         Range("B" & i & ":B" & j & ", C" & i & ":C" & j & ", D" & i & ":D" & j & ", E" & i & ":E" & j & ", F" & i & ":F" & j).Merge
  50.         Range("G" & i & ":G" & j & ", H" & i & ":H" & j & ", I" & i & ":I" & j & ", J" & i & ":J" & j & ", K" & i & ":K" & j).Merge
  51.         Range("L" & i & ":L" & j & ", M" & i & ":M" & j & ", N" & i & ":N" & j & ", O" & i & ":O" & j & ", P" & i & ":P" & j).Merge
  52.     Next i
  53.  
  54.     'Time to Style
  55.  
  56.     'Cell Format cells for date and shift times, this used the same code found in "Format Cells" within excel.
  57.    Range("B2:N2").NumberFormat = "dd-mm-yyyy"
  58.     Range("B5:O20").NumberFormat = "hh:mm AM/PM"
  59.    
  60.     'MainColor
  61.    Range("A4:P4,A21:P21").Interior.Color = RGB(231, 230, 230)
  62.    
  63.     'Color 1 - Odd Rows
  64.    For i = 5 To 20 Step 4
  65.         j = i + 1
  66.         Range("A" & i & ":P" & j).Interior.Color = RGB(255, 255, 255)
  67.     Next i
  68.    
  69.     'Color 2 - Even Rows
  70.    For i = 7 To 20 Step 4
  71.         j = i + 1
  72.         Range("A" & i & ":P" & j).Interior.Color = RGB(242, 242, 242)
  73.     Next i
  74.    
  75.     'Borders
  76.        
  77.      'Shift Area
  78.    With Range("B2:P21")
  79.         With .Borders
  80.             .LineStyle = xlContinuous
  81.             .Weight = xlThin
  82.         End With
  83.     End With
  84.    
  85.     'Shift area Thick Borders
  86.    For i = 2 To 21
  87.         With Range("D" & i & ", F" & i & ", H" & i & ", J" & i & ", L" & i & ", N" & i & ", P" & i).Borders(xlEdgeLeft)
  88.             .LineStyle = xlContinuous
  89.             .Weight = xlMedium
  90.         End With
  91.     Next i
  92.    
  93.     'Employee Area
  94.    For i = 5 To 20 Step 4
  95.         j = i + 1
  96.         Range("A" & i & ":A" & j).BorderAround LineStyle:=xlContinuous, Weight:=xlThin
  97.     Next i
  98.  
  99.     'Employee, Total Hours Column A Cells
  100.    With Range("A4,A21")
  101.         With .Borders
  102.             .LineStyle = xlContinuous
  103.             .Weight = xlThin
  104.         End With
  105.     End With
  106.  
  107. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement