Skip to content
The Chat Archive
gpt-4-0314· OpenAI WildChat-4.8M (AI2)

Write me an Excel code that I have math, English, physics, and history classes from…

  1. User

    Write me an Excel code that I have math, English, physics, and history classes from Monday to Friday from 10:00 AM to 3:30 PM.

  2. Assistant

    Here is an Excel code to create a schedule for the classes you mentioned. Remember to paste the code into a new module in the Excel Visual Basic for Applications (VBA) Editor (ALT + F11). After you run the code (F5), it will create a new sheet with the schedule.

    Sub ClassSchedule()
        Dim ws As Worksheet
        Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        ws.Name = "Schedule"
    
        ' Headers
        ws.Range("B1:G1").Value = Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
        ws.Range("A2:A6").Value = Application.Transpose(Array("10:00 AM - 11:30 AM", "11:30 AM - 1:00 PM", "1:00 PM - 2:30 PM", "2:30 PM - 3:30 PM"))
        
        ' Classes
        ws.Range("B2:G6").Value = Array(Array("Math", "English", "Physics", "History", "Math"), _
                                         Array("Physics", "Math", "History", "English", "Physics"), _
                                         Array("English", "History", "Math", "Physics", "English"), _
                                         Array("History", "Physics", "English", "Math", "History"))
    
        ' Formatting
        With ws.Range("A1:G6")
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Borders(xlEdgeLeft).LineStyle = xlContinuous
            .Borders(xlEdgeTop).LineStyle = xlContinuous
            .Borders(xlEdgeBottom).LineStyle = xlContinuous
            .Borders(xlEdgeRight).LineStyle = xlContinuous
            .Borders(xlInsideHorizontal).LineStyle = xlContinuous
            .Borders(xlInsideVertical).LineStyle = xlContinuous
        End With
    
        With ws.Range("A1:A6")
            .Font.Bold = True
            .Interior.Color = RGB(197, 217, 241)
        End With
    
        With ws.Range("B1:G1")
            .Font.Bold = True
            .Interior.Color = RGB(197, 217, 241)
        End With
    
        ws.Columns.AutoFit
        ws.Rows.AutoFit
    End Sub
    

    After running the code, you will get a table where each row represents a time slot and each column represents a day of the week. The subjects are assigned to the days and time slots according to your specified requirements. The table output should look like this:

    MondayTuesdayWednesdayThursdayFriday
    10:00 AM - 11:30 AMMathEnglishPhysicsHistoryMath
    11:30 AM - 1:00 PMPhysicsMathHistoryEnglishPhysics
    1:00 PM - 2:30 PMEnglishHistoryMathPhysicsEnglish
    2:30 PM - 3:30 PMHistoryPhysicsEnglishMathHistory

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.