Untitled
Anonymous
Plain Text
09/08/2025 10:09 PM
24.6 KB
19
Indexable
Never
Option Explicit
' ==================================================
' College Schedule Visualizer (All-in-One)
' Grid + Day Headers + Right Timeline + Pills + Toggles
' Animations (press, fade), Settings Panel slide/contents
' Warnings popup, clipping arrows, person color theming
' ==================================================
' ---------- Layout constants ----------
Private Const GRID_LEFT As Double = 100
Private Const GRID_RIGHT As Double = 700
Private Const GRID_TOP As Double = 80
Private Const MINUTE_PX As Double = 2 ' 2 px per minute
Private Const DAY_COL_WIDTH As Double = 120 ' column width per day
Private Const PILL_WIDTH As Double = 110
Private Const HEADER_TOP As Double = 40
Private Const HEADER_HEIGHT As Double = 24
' Days
Private dayNames As Variant
' ===============================
' ?? Person Colors
' ===============================
Public Function GetPersonColor(person As String) As Long
Select Case LCase(person)
Case "alice": GetPersonColor = RGB(255, 100, 100) ' red
Case "bob": GetPersonColor = RGB(100, 150, 255) ' blue
Case "charlie": GetPersonColor = RGB(120, 200, 120) ' green
Case Else: GetPersonColor = RGB(200, 200, 200)
End Select
End Function
' ===============================
' ?? Button Press Animation
' ===============================
Public Sub AnimateButtonPress(shpName As String)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim shp As Shape
On Error Resume Next
Set shp = ws.Shapes(shpName)
If shp Is Nothing Then Exit Sub
' press
shp.ScaleWidth 0.95, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 0.95, msoFalse, msoScaleFromMiddle
shp.Fill.Transparency = 0.3
DoEvents: Application.Wait Now + TimeValue("00:00:00.07")
' bounce
shp.ScaleWidth 1.11, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 1.11, msoFalse, msoScaleFromMiddle
shp.Fill.Transparency = 0.1
DoEvents: Application.Wait Now + TimeValue("00:00:00.07")
' settle
shp.ScaleWidth 0.95, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 0.95, msoFalse, msoScaleFromMiddle
shp.Fill.Transparency = 0
On Error GoTo 0
End Sub
' ===============================
' ?? Optional: Button Hover Animation (call if you wire it)
' ===============================
Public Sub AnimateButtonHover(shpName As String, isHover As Boolean)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim shp As Shape
On Error Resume Next
Set shp = ws.Shapes(shpName)
If shp Is Nothing Then Exit Sub
On Error GoTo 0
If isHover Then
shp.ScaleWidth 1.05, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 1.05, msoFalse, msoScaleFromMiddle
shp.Line.Weight = 2.5
shp.Line.Transparency = 0.1
If shpName = "Btn_Gear" Then shp.Rotation = shp.Rotation + 15
Else
shp.ScaleWidth 0.95, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 0.95, msoFalse, msoScaleFromMiddle
shp.Line.Weight = 1.5
shp.Line.Transparency = 0.3
If shpName = "Btn_Gear" Then shp.Rotation = 0
End If
End Sub
' ===============================
' ?? Fade class blocks for a person (show/hide with animation)
' ===============================
Public Sub FadeClassBlocks(person As String, fadeIn As Boolean)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim shp As Shape, i As Integer, targetName As String
targetName = "Class_" & person & "_*"
For Each shp In ws.Shapes
If shp.Name Like targetName Then
If fadeIn Then
shp.Visible = msoTrue
For i = 8 To 2 Step -1
shp.Fill.Transparency = i / 10
shp.Line.Transparency = i / 10
shp.ScaleWidth 1.02, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 1.02, msoFalse, msoScaleFromMiddle
DoEvents: Application.Wait Now + TimeValue("00:00:00.05")
Next i
shp.Fill.Transparency = 0.25
shp.Line.Transparency = 0.2
shp.ScaleWidth 0.98, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 0.98, msoFalse, msoScaleFromMiddle
Else
For i = 2 To 8
shp.Fill.Transparency = i / 10
shp.Line.Transparency = i / 10
shp.ScaleWidth 0.98, msoFalse, msoScaleFromMiddle
shp.ScaleHeight 0.98, msoFalse, msoScaleFromMiddle
DoEvents: Application.Wait Now + TimeValue("00:00:00.05")
Next i
shp.Visible = msoFalse
End If
End If
Next shp
End Sub
' ===============================
' ?? Settings Panel (slide in/out) + staged contents
' Shapes expected:
' Panel_Settings, Lbl_Settings,
' Swatch_Alice, Chk_Alice, Swatch_Bob, Chk_Bob, Swatch_Charlie, Chk_Charlie,
' Btn_Apply
' ===============================
Public Sub AnimatePanel(showPanel As Boolean)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim p As Shape, i As Integer
On Error Resume Next
Set p = ws.Shapes("Panel_Settings")
If p Is Nothing Then Exit Sub
On Error GoTo 0
If showPanel Then
p.Visible = msoTrue
p.Fill.Transparency = 1
p.Line.Transparency = 1
p.Left = p.Left + 50
For i = 10 To 2 Step -1
p.Fill.Transparency = i / 10
p.Line.Transparency = i / 10
p.Left = p.Left - 5
DoEvents: Application.Wait Now + TimeValue("00:00:00.03")
Next i
p.Fill.Transparency = 0.2
p.Line.Transparency = 0.2
AnimatePanelContents True
Else
AnimatePanelContents False
For i = 2 To 10
p.Fill.Transparency = i / 10
p.Line.Transparency = i / 10
p.Left = p.Left + 5
DoEvents: Application.Wait Now + TimeValue("00:00:00.03")
Next i
p.Visible = msoFalse
End If
End Sub
Public Sub AnimatePanelContents(showPanel As Boolean)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim names As Variant, nm As Variant, s As Shape, i As Integer, startTop As Double
names = Array("Lbl_Settings", _
"Swatch_Alice", "Chk_Alice", _
"Swatch_Bob", "Chk_Bob", _
"Swatch_Charlie", "Chk_Charlie", _
"Btn_Apply")
If showPanel Then
For Each nm In names
On Error Resume Next
Set s = ws.Shapes(nm)
If Not s Is Nothing Then
s.Visible = msoTrue
startTop = s.Top
s.Top = startTop - 5
s.Fill.Transparency = 1
s.Line.Transparency = 1
For i = 10 To 2 Step -2
s.Fill.Transparency = i / 10
s.Line.Transparency = i / 10
s.Top = s.Top + 1
DoEvents: Application.Wait Now + TimeValue("00:00:00.04")
Next i
s.Fill.Transparency = 0
s.Line.Transparency = 0.2
s.Top = startTop
If s.Name = "Btn_Apply" Then
s.Top = s.Top + 2: DoEvents
Application.Wait Now + TimeValue("00:00:00.05")
s.Top = s.Top - 2
End If
End If
On Error GoTo 0
Next nm
Else
For Each nm In names
On Error Resume Next
Set s = ws.Shapes(nm)
If Not s Is Nothing Then
For i = 2 To 10 Step 2
s.Fill.Transparency = i / 10
s.Line.Transparency = i / 10
DoEvents: Application.Wait Now + TimeValue("00:00:00.02")
Next i
s.Visible = msoFalse
End If
On Error GoTo 0
Next nm
End If
End Sub
Public Sub ToggleSettingsPanel()
AnimateButtonPress "Btn_Gear"
Static isVisible As Boolean
If isVisible Then
AnimatePanel False: isVisible = False
Else
AnimatePanel True: isVisible = True
End If
End Sub
' ===============================
' ?? Draw Grid (Mon–Fri headers + right-side timeline)
' - 5-min full grid lines
' - 30-min & hourly emphasized
' - Day headers across top
' - Time labels on RIGHT side
' Named inputs required on sheet "Schedule":
' Input_StartTime, Input_EndTime
' ===============================
Public Sub DrawScheduleGrid()
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim shp As Shape, t As Date, y As Double, i As Long
Dim startTime As Date, endTime As Date
dayNames = Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
' Clean old grid items
For Each shp In ws.Shapes
If Left(shp.Name, 5) = "Grid_" Or Left(shp.Name, 9) = "HeaderDay" Or Left(shp.Name, 9) = "TimeText_" Then
shp.Delete
End If
Next shp
On Error Resume Next
startTime = ws.Range("Input_StartTime").Value
endTime = ws.Range("Input_EndTime").Value
On Error GoTo 0
If startTime = 0 Then startTime = TimeValue("08:00")
If endTime = 0 Then endTime = TimeValue("22:00")
' Day headers
For i = 0 To 4
Set shp = ws.Shapes.AddTextbox(msoTextOrientationHorizontal, _
GRID_LEFT + i * DAY_COL_WIDTH, HEADER_TOP, DAY_COL_WIDTH, HEADER_HEIGHT)
shp.Name = "HeaderDay_" & (i + 1)
With shp.TextFrame2
.TextRange.Text = dayNames(i)
.TextRange.ParagraphFormat.Alignment = msoAlignCenter
.TextRange.Font.Bold = True
.TextRange.Font.Size = 11
End With
shp.Line.Visible = msoFalse
shp.Fill.Visible = msoFalse
End If
' 5-min lines + right-side labels (every 30 min)
i = 0
For t = startTime To endTime Step TimeSerial(0, 5, 0)
y = GRID_TOP + ((t - startTime) * 24 * 60) * MINUTE_PX
' grid line
Set shp = ws.Shapes.AddLine(GRID_LEFT, y, GRID_RIGHT, y)
shp.Name = "Grid_Line_" & Format(t, "hhmm")
With shp.Line
If Minute(t) = 0 Then
.ForeColor.RGB = RGB(0, 0, 0): .Weight = 1.5
ElseIf Minute(t) = 30 Then
.ForeColor.RGB = RGB(80, 80, 80): .Weight = 1
Else
.ForeColor.RGB = RGB(215, 215, 215): .Weight = 0.5
End If
End With
' right-side label (every 30 minutes)
If Minute(t) Mod 30 = 0 Then
Set shp = ws.Shapes.AddTextbox(msoTextOrientationHorizontal, GRID_RIGHT + 8, y - 8, 60, 16)
shp.Name = "TimeText_" & Format(t, "hhmm")
With shp.TextFrame2
.TextRange.Text = Format(t, "h:mm AM/PM")
.TextRange.Font.Size = 8
.TextRange.ParagraphFormat.Alignment = msoAlignLeft
End With
shp.Line.Visible = msoFalse
shp.Fill.Visible = msoFalse
End If
i = i + 1
Next t
End Sub
' ===============================
' ?? Apply: draws pills, honors toggles, clipping arrows,
' transparency for overlaps, warnings + popup
' Requires:
' - Sheet "Data" columns: Class | Person | Day | Start | End
' - Named cells on "Schedule":
' Input_StartTime, Input_EndTime,
' State_Alice, State_Bob, State_Charlie, Warnings
' - Buttons: Btn_Apply, Btn_Alice, Btn_Bob, Btn_Charlie, Btn_Gear
' ===============================
Public Sub ApplySchedule()
Dim wsSched As Worksheet, wsData As Worksheet
Dim startTime As Date, endTime As Date
Dim lastRow As Long, r As Long
Dim className As String, person As String, day As String
Dim tStart As Date, tEnd As Date
Dim colDay As Long, x As Double, y As Double, h As Double
Dim shp As Shape
Dim warningText As String
Dim adjStart As Date, adjEnd As Date
Dim showTopArrow As Boolean, showBottomArrow As Boolean
Dim labelText As String
Dim showAlice As Boolean, showBob As Boolean, showCharlie As Boolean
Set wsSched = ThisWorkbook.Worksheets("Schedule")
Set wsData = ThisWorkbook.Worksheets("Data")
AnimateButtonPress "Btn_Apply"
' Clear old class blocks
For Each shp In wsSched.Shapes
If Left(shp.Name, 6) = "Class_" Then shp.Delete
Next shp
' Time window
startTime = IIf(wsSched.Range("Input_StartTime").Value = 0, TimeValue("08:00"), wsSched.Range("Input_StartTime").Value)
endTime = IIf(wsSched.Range("Input_EndTime").Value = 0, TimeValue("22:00"), wsSched.Range("Input_EndTime").Value)
' Redraw grid
DrawScheduleGrid
' Read toggle states (who should be drawn)
showAlice = CBool(wsSched.Range("State_Alice").Value)
showBob = CBool(wsSched.Range("State_Bob").Value)
showCharlie = CBool(wsSched.Range("State_Charlie").Value)
warningText = "Warnings:"
' Loop data
lastRow = wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
For r = 2 To lastRow
className = Trim$(wsData.Cells(r, 1).Value)
person = Trim$(wsData.Cells(r, 2).Value)
day = Trim$(wsData.Cells(r, 3).Value)
tStart = wsData.Cells(r, 4).Value
tEnd = wsData.Cells(r, 5).Value
If className = "" Or person = "" Or day = "" Then GoTo NextRow
' honor toggles
Select Case LCase(person)
Case "alice": If Not showAlice Then GoTo NextRow
Case "bob": If Not showBob Then GoTo NextRow
Case "charlie": If Not showCharlie Then GoTo NextRow
End Select
' which day column?
Select Case LCase(day)
Case "monday": colDay = 0
Case "tuesday": colDay = 1
Case "wednesday": colDay = 2
Case "thursday": colDay = 3
Case "friday": colDay = 4
Case Else: colDay = -1
End Select
If colDay < 0 Then GoTo NextRow
' visible clipping
adjStart = tStart: adjEnd = tEnd
showTopArrow = False: showBottomArrow = False
If tStart < startTime Then adjStart = startTime: showTopArrow = True
If tEnd > endTime Then adjEnd = endTime: showBottomArrow = True
If showTopArrow Or showBottomArrow Then
warningText = warningText & vbCrLf & "? " & className & " (" & person & ") on " & day & " is partly outside visible range"
End If
If adjStart >= adjEnd Then
warningText = warningText & vbCrLf & "? " & className & " (" & person & ") on " & day & " is fully outside visible range"
GoTo NextRow
End If
' positions
x = GRID_LEFT + colDay * DAY_COL_WIDTH + (DAY_COL_WIDTH - PILL_WIDTH) / 2
y = GRID_TOP + ((adjStart - startTime) * 24 * 60) * MINUTE_PX
h = ((adjEnd - adjStart) * 24 * 60) * MINUTE_PX
' pill
Set shp = wsSched.Shapes.AddShape(msoShapeRoundedRectangle, x, y, PILL_WIDTH, h)
shp.Name = "Class_" & person & "_" & r
' label: top-aligned; only title + person at top (as requested earlier)
labelText = ""
If showTopArrow Then labelText = "?" & vbCrLf
labelText = labelText & className & " — " & person
If showBottomArrow Then labelText = labelText & vbCrLf & "?"
With shp.TextFrame2
.VerticalAnchor = msoAnchorTop
.MarginTop = 4: .MarginLeft = 6: .MarginRight = 6: .MarginBottom = 4
.AutoSize = msoAutoSizeNone
.TextRange.Text = labelText
.TextRange.Font.Size = 9
End With
shp.Fill.ForeColor.RGB = GetPersonColor(person)
shp.Fill.Transparency = IIf(showTopArrow Or showBottomArrow, 0.6, 0.25)
shp.Line.Visible = msoFalse
NextRow:
Next r
' popup warnings + write cell
wsSched.Range("Warnings").Value = warningText
If warningText <> "Warnings:" Then
MsgBox warningText, vbExclamation, "Schedule Warnings"
End If
' gentle fade-in for whichever are ON
If showAlice Then FadeClassBlocks "Alice", True
If showBob Then FadeClassBlocks "Bob", True
If showCharlie Then FadeClassBlocks "Charlie", True
End Sub
' ===============================
' ?? Toggle buttons (Alice/Bob/Charlie)
' - animate press
' - update button look (solid vs faded)
' - fade class blocks in/out
' ===============================
Public Sub ToggleAlice(): TogglePerson "Alice", "Btn_Alice": End Sub
Public Sub ToggleBob(): TogglePerson "Bob", "Btn_Bob": End Sub
Public Sub ToggleCharlie(): TogglePerson "Charlie", "Btn_Charlie": End Sub
Private Sub TogglePerson(person As String, btnName As String)
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Schedule")
Dim btn As Shape
AnimateButtonPress btnName
' flip state
ws.Range("State_" & person).Value = Not CBool(ws.Range("State_" & person).Value)
' button visual state
Set btn = ws.Shapes(btnName)
btn.Fill.ForeColor.RGB = GetPersonColor(person)
If ws.Range("State_" & person).Value Then
' ON
btn.Fill.Transparency = 0
btn.Line.Weight = 2
' fade in blocks
FadeClassBlocks person, True
Else
' OFF
btn.Fill.Transparency = 0.7
btn.Line.Weight = 1
' fade out blocks
FadeClassBlocks person, False
End If
End Sub
Sub SetupScheduleSheet()
Dim ws As Worksheet
Dim btn As Shape
' Ensure the Schedule sheet exists
On Error Resume Next
Set ws = ThisWorkbook.Worksheets("Schedule")
If ws Is Nothing Then
Set ws = ThisWorkbook.Worksheets.Add
ws.Name = "Schedule"
End If
On Error GoTo 0
ws.Cells.Clear
' -------------------------
' Input Time Ranges
' -------------------------
ws.Range("B2").Value = "Start Time:"
ws.Range("C2").Value = "8:00 AM"
ThisWorkbook.names.Add Name:="Input_StartTime", RefersTo:=ws.Range("C2")
ws.Range("B3").Value = "End Time:"
ws.Range("C3").Value = "10:00 PM"
ThisWorkbook.names.Add Name:="Input_EndTime", RefersTo:=ws.Range("C3")
' -------------------------
' Toggle States
' -------------------------
ws.Range("B5").Value = "Alice Visible?"
ws.Range("C5").Value = True
ThisWorkbook.names.Add Name:="State_Alice", RefersTo:=ws.Range("C5")
ws.Range("B6").Value = "Bob Visible?"
ws.Range("C6").Value = True
ThisWorkbook.names.Add Name:="State_Bob", RefersTo:=ws.Range("C6")
ws.Range("B7").Value = "Charlie Visible?"
ws.Range("C7").Value = True
ThisWorkbook.names.Add Name:="State_Charlie", RefersTo:=ws.Range("C7")
' -------------------------
' Warnings Cell
' -------------------------
ws.Range("B9").Value = "Warnings:"
ws.Range("C9").Value = "Warnings:"
ThisWorkbook.names.Add Name:="Warnings", RefersTo:=ws.Range("C9")
' -------------------------
' Buttons
' -------------------------
' Apply Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 350, 20, 100, 30)
btn.Name = "Btn_Apply"
btn.TextFrame2.TextRange.Text = "Apply"
btn.OnAction = "ApplySchedule"
' Alice Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 470, 20, 80, 30)
btn.Name = "Btn_Alice"
btn.TextFrame2.TextRange.Text = "Alice"
btn.OnAction = "ToggleAlice"
' Bob Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 560, 20, 80, 30)
btn.Name = "Btn_Bob"
btn.TextFrame2.TextRange.Text = "Bob"
btn.OnAction = "ToggleBob"
' Charlie Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 650, 20, 80, 30)
btn.Name = "Btn_Charlie"
btn.TextFrame2.TextRange.Text = "Charlie"
btn.OnAction = "ToggleCharlie"
' Gear Button
Set btn = ws.Shapes.AddShape(msoShapeOval, 750, 20, 30, 30)
btn.Name = "Btn_Gear"
btn.TextFrame2.TextRange.Text = "?"
btn.OnAction = "ToggleSettingsPanel"
MsgBox "? Schedule sheet has been set up with input cells, named ranges, and buttons.", vbInformation
End Sub
Sub SetupWorkbook()
Call SetupScheduleSheet
Call SetupDataSheet
MsgBox "? Workbook has been fully set up with Schedule and Data sheets.", vbInformation
End Sub
Sub SetupScheduleSheet()
Dim ws As Worksheet
Dim btn As Shape
' Ensure Schedule sheet exists
On Error Resume Next
Set ws = ThisWorkbook.Worksheets("Schedule")
If ws Is Nothing Then
Set ws = ThisWorkbook.Worksheets.Add
ws.Name = "Schedule"
End If
On Error GoTo 0
ws.Cells.Clear
' -------------------------
' Input Time Ranges
' -------------------------
ws.Range("B2").Value = "Start Time:"
ws.Range("C2").Value = "8:00 AM"
ThisWorkbook.names.Add Name:="Input_StartTime", RefersTo:=ws.Range("C2")
ws.Range("B3").Value = "End Time:"
ws.Range("C3").Value = "10:00 PM"
ThisWorkbook.names.Add Name:="Input_EndTime", RefersTo:=ws.Range("C3")
' -------------------------
' Toggle States
' -------------------------
ws.Range("B5").Value = "Alice Visible?"
ws.Range("C5").Value = True
ThisWorkbook.names.Add Name:="State_Alice", RefersTo:=ws.Range("C5")
ws.Range("B6").Value = "Bob Visible?"
ws.Range("C6").Value = True
ThisWorkbook.names.Add Name:="State_Bob", RefersTo:=ws.Range("C6")
ws.Range("B7").Value = "Charlie Visible?"
ws.Range("C7").Value = True
ThisWorkbook.names.Add Name:="State_Charlie", RefersTo:=ws.Range("C7")
' -------------------------
' Warnings Cell
' -------------------------
ws.Range("B9").Value = "Warnings:"
ws.Range("C9").Value = "Warnings:"
ThisWorkbook.names.Add Name:="Warnings", RefersTo:=ws.Range("C9")
' -------------------------
' Buttons
' -------------------------
' Apply Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 350, 20, 100, 30)
btn.Name = "Btn_Apply"
btn.TextFrame2.TextRange.Text = "Apply"
btn.OnAction = "ApplySchedule"
' Alice Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 470, 20, 80, 30)
btn.Name = "Btn_Alice"
btn.TextFrame2.TextRange.Text = "Alice"
btn.OnAction = "ToggleAlice"
' Bob Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 560, 20, 80, 30)
btn.Name = "Btn_Bob"
btn.TextFrame2.TextRange.Text = "Bob"
btn.OnAction = "ToggleBob"
' Charlie Button
Set btn = ws.Shapes.AddShape(msoShapeRoundedRectangle, 650, 20, 80, 30)
btn.Name = "Btn_Charlie"
btn.TextFrame2.TextRange.Text = "Charlie"
btn.OnAction = "ToggleCharlie"
' Gear Button
Set btn = ws.Shapes.AddShape(msoShapeOval, 750, 20, 30, 30)
btn.Name = "Btn_Gear"
btn.TextFrame2.TextRange.Text = "?"
btn.OnAction = "ToggleSettingsPanel"
End Sub
' ===============================
' Build Data Sheet
' ===============================
Sub SetupDataSheet()
Dim ws As Worksheet
' Ensure Data sheet exists
On Error Resume Next
Set ws = ThisWorkbook.Worksheets("Data")
If ws Is Nothing Then
Set ws = ThisWorkbook.Worksheets.Add
ws.Name = "Data"
End If
On Error GoTo 0
ws.Cells.Clear
' -------------------------
' Headers
' -------------------------
ws.Range("A1").Value = "Class"
ws.Range("B1").Value = "Person"
ws.Range("C1").Value = "Day"
ws.Range("D1").Value = "Start"
ws.Range("E1").Value = "End"
' -------------------------
' Example Rows
' -------------------------
ws.Range("A2").Value = "Math"
ws.Range("B2").Value = "Alice"
ws.Range("C2").Value = "Monday"
ws.Range("D2").Value = "9:00 AM"
ws.Range("E2").Value = "10:00 AM"
ws.Range("A3").Value = "Science"
ws.Range("B3").Value = "Bob"
ws.Range("C3").Value = "Monday"
ws.Range("D3").Value = "9:30 AM"
ws.Range("E3").Value = "11:00 AM"
ws.Range("A4").Value = "History"
ws.Range("B4").Value = "Charlie"
ws.Range("C4").Value = "Tuesday"
ws.Range("D4").Value = "1:00 PM"
ws.Range("E4").Value = "2:30 PM"
ws.Range("A5").Value = "English"
ws.Range("B5").Value = "Alice"
ws.Range("C5").Value = "Wednesday"
ws.Range("D5").Value = "10:00 AM"
ws.Range("E5").Value = "11:30 AM"
ws.Columns("A:E").AutoFit
End Sub
Editor is loading...
Leave a Comment