S
Seth J. Turok
I am an ultra novice and am trying to teach myself VBA using "Excel
VBA Programming for Dummies". I have attempted to insert some of the
sample code provided in the book. I appear to get the same error
message when I execute the code, “compile error: variable not
defined”. The two examples I have used are below. I was hoping you
might be able to tell me what I am doing incorrectly. Thank you.
EXAMPLE 1
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
Example 2
Answer = MsgBox("Convert formulas to values?", vbYesNo)
If Answer <> vbYes Then Exit Sub
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
VBA Programming for Dummies". I have attempted to insert some of the
sample code provided in the book. I appear to get the same error
message when I execute the code, “compile error: variable not
defined”. The two examples I have used are below. I was hoping you
might be able to tell me what I am doing incorrectly. Thank you.
EXAMPLE 1
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
Example 2
Answer = MsgBox("Convert formulas to values?", vbYesNo)
If Answer <> vbYes Then Exit Sub
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False