Nested If-Elseif-Else loop involving dates in VBA

bglanton

New Member
Joined
Oct 3, 2014
Messages
10
Please help me write this code. Thanks!!


  1. Ask the user to enter date.
  2. If the user enters date between January – May
    1. Display: “Online Class Only!”
  3. If the user enters date between June – July
    1. Display: “No class available!”
  4. If the user enters date between August – November
    1. Display: “Two Class Options available”
    2. Ask the user to enter to make a choice, Option 1 for Monday/Wednesday Friday OR Option 2 for Tuesday/Thursday
    3. If the user selects Monday/Wednesday/Friday, display: “Class hours as 11:00-11:50pm”
    4. If the user selects Tuesday/Thursday, display: “Class hours as 2:15-3:30pm”
    5. Else display: “Weekend has no classes!”
  5. In other cases, display: “Semester Break!”
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Something like this?

Code:
Sub ClassSchedules()
    userDate = InputBox("Please enter the date you would like to check:", "Class Schedules")
    
    
    Select Case Month(userDate)
    Case 1 To 5
        MsgBox "Online Class Only!", vbExclamation, "Response"
    Case 6 To 7
        MsgBox "No class available!", vbExclamation, "Response"
    Case 8 To 11
        userChoice = InputBox("Two class options available:" & vbCrLf & _
            "     Option 1: Mon/Wed/Fri 11:00pm - 11:50pm" & vbCrLf & _
            "     Option 2: Tue/Thu     2:15pm - 3:30pm" & vbCrLf & vbCrLf & _
            "Type either '1' OR '2'", "Choose an option")
        If userChoice <> 1 And userChoice <> 2 Then MsgBox "Weekend has no classes!", vbExclamation, "Response"
        
        MsgBox "You have chosen Option #" & userChoice, vbOKOnly + vbInformation
    Case Else
        MsgBox "Semester Break!", vbExclamation, "Response"
    End Select
    
    
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,537
Messages
6,120,096
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top