I am working through EXCEL VBA Programming for Dummies from 2004. I am getting the "Compile error: Variable not defined" pop-up. Below is what my code looks like and it is verbatim as the example in the book. I know the problem has something to do with the "Option Explicit" at the top and that I need to define my variables, but I don't know how to write the code.
Option Explicit
Sub GuessName()
Msg = "Is your name" & Application.UserName & "?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then MsgBox "Oh, never mind."
If Ans = vbYes Then MsgBox "I must be clairvoyant!"
End Sub
Option Explicit
Sub GuessName()
Msg = "Is your name" & Application.UserName & "?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then MsgBox "Oh, never mind."
If Ans = vbYes Then MsgBox "I must be clairvoyant!"
End Sub