Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Compile Error: Variable Not Defined

i am getting a compile error: variable not defined message on the following
line of code...

FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

i never had this problem before, and wonder if i may have changed a setting
somewhere and am not sure what needs to be changed to get it to work again.
i tried going into options and unchecking the Require Variable Declaration
box in the Editor tab, but that didn't work.

how do i remedy?

thanks!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Compile Error: Variable Not Defined

Dim FinalRow2009 As Long
FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

If this post helps click Yes
---------------
Jacob Skaria


"joemeshuggah" wrote:

i am getting a compile error: variable not defined message on the following
line of code...

FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

i never had this problem before, and wonder if i may have changed a setting
somewhere and am not sure what needs to be changed to get it to work again.
i tried going into options and unchecking the Require Variable Declaration
box in the Editor tab, but that didn't work.

how do i remedy?

thanks!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Compile Error: Variable Not Defined

Do you have Option Explicit statement on top of the module...

If this post helps click Yes
---------------
Jacob Skaria


"joemeshuggah" wrote:

i am getting a compile error: variable not defined message on the following
line of code...

FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

i never had this problem before, and wonder if i may have changed a setting
somewhere and am not sure what needs to be changed to get it to work again.
i tried going into options and unchecking the Require Variable Declaration
box in the Editor tab, but that didn't work.

how do i remedy?

thanks!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Compile Error: Variable Not Defined

The fix is to declare all of your variables. It is VERY poor coding practice
to not declare your variables.

Dim FinalRow2009 as long

FinalRow2009 = Cells(Rows.Count, "A").End(xlUp).Row

Require variable declarations just inserts the line Option Explicit at the
top of all new code modules. If that line exists in a module then it will
enforce varaible declarations. That is a good thing and it is in ALL well
written code. If option explicit is not included then the compiler will allow
on the fly variables which are a nightmare to debug.
--
HTH...

Jim Thomlinson


"joemeshuggah" wrote:

i am getting a compile error: variable not defined message on the following
line of code...

FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

i never had this problem before, and wonder if i may have changed a setting
somewhere and am not sure what needs to be changed to get it to work again.
i tried going into options and unchecking the Require Variable Declaration
box in the Editor tab, but that didn't work.

how do i remedy?

thanks!!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Compile Error: Variable Not Defined

in the vba development environment (the IDE) from the menu select Tools then
Options
In the Options window, the Editor tab is showing, make sure you check the
'Require Variable Declaration' box - this will then automatically add
OPTION EXPLICIT
to all new modules

before running code, be sure to Debug/Compile too .. thsi will pick up
errors in sybtax or names too



"joemeshuggah" wrote:

i am getting a compile error: variable not defined message on the following
line of code...

FinalRow2009 = Cells(Cells.Rows.Count, "A").End(xlUp).Row

i never had this problem before, and wonder if i may have changed a setting
somewhere and am not sure what needs to be changed to get it to work again.
i tried going into options and unchecking the Require Variable Declaration
box in the Editor tab, but that didn't work.

how do i remedy?

thanks!!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error: Variable not defined Hennie Neuhoff Excel Programming 2 November 10th 08 02:37 AM
Variable not Defined Compile error Paul3rd Excel Programming 15 January 5th 08 03:22 AM
Compile error, Variable not defined RJR[_2_] Excel Programming 4 March 23rd 07 02:21 AM
Variable not defined compile error Phil Hageman[_4_] Excel Programming 4 June 17th 05 01:52 PM
Compile error, variable not defined davegb Excel Programming 5 May 19th 05 04:41 PM


All times are GMT +1. The time now is 06:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"