Jon von der Heyden
MrExcel MVP, Moderator
- Joined
- Apr 6, 2004
- Messages
- 10,912
- Office Version
- 365
- Platform
- Windows
The best way to idiot-proof your spreadsheets is to forbid idiots from using them.
In ThisWorkbook Module
To be EXTRA mean I thought about failing the individual even if they answer all of the questions correctly only because a smart person would disable macro's and then open the file.
In ThisWorkbook Module
Code:
Option Explicit
Private Type QA
Q As String
A As String
End Type
Private Sub Workbook_Open()
Dim lngMsg As VbMsgBoxResult
Dim qaArray(1 To 20) As QA
Dim lngItem As Long
Dim strAnswer As String
qaArray(1).Q = "With reference to mobile phone networks, what does 3G stand for?": qaArray(1).A = "3rd generation"
qaArray(2).Q = "If you were born on the 29th October, which star sign would you belong to?": qaArray(2).A = "Scorpio"
qaArray(3).Q = "In which year did England and Wales become united with Scotland?": qaArray(3).A = "1707"
qaArray(4).Q = "Which tree produces conkers?": qaArray(4).A = "horse chestnut"
qaArray(5).Q = "The crosses of St George, St Patrick, and St Andrew make up which flag? ": qaArray(5).A = "The Union Jack"
qaArray(6).Q = "What was the name of the first Scottish man to be voted European Footballer of The Year?": qaArray(6).A = "Denis Law"
qaArray(7).Q = "In the 2009 film 'The Hangover' which Las Vegas hotel did the bachelor party stay at?": qaArray(7).A = "Caesars Palace"
qaArray(8).Q = "What is the highest number visible on a dart board?": qaArray(8).A = "20"
qaArray(9).Q = "Who was the ruler of England during the Commonwealth?": qaArray(9).A = "Oliver Cromwell"
qaArray(10).Q = "How many yards are there between the wickets in a game of cricket?": qaArray(10).A = "22"
qaArray(11).Q = "Which breed of dog is believed to be the fastest?": qaArray(11).A = "Greyhound"
qaArray(12).Q = "Who was the author of Peter Rabbit?": qaArray(12).A = "Beatrix Potter"
qaArray(13).Q = "How many lines does a Limerick have?": qaArray(13).A = "5"
qaArray(14).Q = "Who had an 80s hit with the song entitled '99 Red Balloons'?": qaArray(14).A = "Nena"
qaArray(15).Q = "What is the name of the largest river in France?": qaArray(15).A = "Loire"
qaArray(16).Q = "Which famous poet wrote 'An Ode to a Nightingale'?": qaArray(16).A = "John Keats"
qaArray(17).Q = "What is the largest planet in the solar system?": qaArray(17).A = "Jupiter"
qaArray(18).Q = "What is the capital of America?": qaArray(18).A = "Washington DC"
qaArray(19).Q = "In a baseball team, how many players are there?": qaArray(19).A = "9"
qaArray(20).Q = "What is the softest mineral in the world?": qaArray(20).A = "Talc"
Application.EnableCancelKey = xlDisabled
lngMsg = MsgBox(Prompt:="This workbook is intended for smart people only! Are you smart?", _
Buttons:=vbQuestion + vbYesNo, _
Title:="Have you got what it takes?")
If lngMsg = vbNo Then
GoTo fail
Else
lngMsg = MsgBox(Prompt:="Ok! You will now be asked a series of questions!", _
Buttons:=vbExclamation + vbOKCancel, _
Title:="Pop Quiz")
If lngMsg = vbOK Then
For lngItem = LBound(qaArray) To UBound(qaArray)
strAnswer = CStr(Application.InputBox(Prompt:=qaArray(lngItem).Q, Title:="Question " & lngItem, Type:=2))
If strAnswer = "False" Then GoTo fail
If LCase$(strAnswer) <> LCase$(qaArray(lngItem).A) Then
GoTo fail
End If
Next lngItem
Else
GoTo fail
End If
End If
Call MsgBox(Prompt:="Well done! Next time try disabling macro's ;-)", _
Buttons:=vbOKOnly + vbInformation, _
Title:="Hahahahahahaha")
Exit Sub
fail:
Call MsgBox(Prompt:="Sorry but you are not qualified to use this workbook!", _
Buttons:=vbCritical + vbOKOnly, _
Title:="Bye bye")
Call Me.Close(SaveChanges:=False)
End Sub
To be EXTRA mean I thought about failing the individual even if they answer all of the questions correctly only because a smart person would disable macro's and then open the file.