Compile error message not showing

jonnyyyl

New Member
Joined
Nov 9, 2011
Messages
36
I'm using Office 2016 64bit

I am making a real effort to learn VBA. One of my exercises asks me to declare something as follow:

cells (1,2) = yournam (the correct variable is yourname)

when running it, I am told to expect an error message due to the above typo, and I should receive "compile error: variable not defined"

The program ran perfectly fine, and skipped the cell(1,2) command. No error window showed up.

I am not sure what went wrong..?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi jonnyyyl,

I'd bet the instructions have an "Option Explicit" as the first line in the module. This would then give you an error message.
 
Upvote 0
Exactly as Marvin says, if you include "Option Explicit" (minus the quote marks) at the top of each module, then the Compile Error is created, as Option Explicit insists that all variables be declared. Without Option Explicit, yournam is implicitly declared as a Variant and later sub-typed if/when a value is assigned to it. In Help, you can enter "Option Explicit" and the topic will show.

Hope thta helps,

Mark
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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