Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Option Explicit is ignored

Anyone can shine a light on this please?

- I start my module with Option Explicit
- In options I also have Require Variable Declaration checked

In my code I use a variable that I did not declare in the Dim section.

Yet, I can still run my code......... without the compliler triggering me
that I forgot to declare the variable.

I do not want this, what should I do to make the option explicit enforced?

Thanks!

M.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Option Explicit is ignored

Probably you have that variable declared globally (Public) or at module
level (Private). Do a search in your project.

RBS


"Michiel via OfficeKB.com" <u40062@uwe wrote in message
news:9e61b99e2ab81@uwe...
Anyone can shine a light on this please?

- I start my module with Option Explicit
- In options I also have Require Variable Declaration checked

In my code I use a variable that I did not declare in the Dim section.

Yet, I can still run my code......... without the compliler triggering me
that I forgot to declare the variable.

I do not want this, what should I do to make the option explicit enforced?

Thanks!

M.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Option Explicit is ignored

i've seen this occasionally. code will run fine, then all of a sudden i get the
error that a variable is not defined. never found out what causes it, as it
doesn't happen very often.

--


Gary Keramidas
Excel 2003


"Michiel via OfficeKB.com" <u40062@uwe wrote in message
news:9e61b99e2ab81@uwe...
Anyone can shine a light on this please?

- I start my module with Option Explicit
- In options I also have Require Variable Declaration checked

In my code I use a variable that I did not declare in the Dim section.

Yet, I can still run my code......... without the compliler triggering me
that I forgot to declare the variable.

I do not want this, what should I do to make the option explicit enforced?

Thanks!

M.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Option Explicit is ignored

I simplified the code since it was a lot of code.

But in this example it still occurs.

I searched for the variable in other modules but it is not found anywhere

M.

-------------------

Option Explicit
'Constants to define where the columns of interest are in the input file
eSec_Blackrock_SSB 9_10 Breakdown.xls
Const cBAssetCat = 1
Const cBAccount = 2
Const cBCusip = 8

'Constants to define where the columns of interest are in the input file
Security Valuation.xls
Const cVRepAccNo = 1
Const cVMellonSec = 7
Const cVShpPar = 16
Const cVLocalPric = 24
Const cVLocMV = 26

'Constants to define where the columns of interest go in the output report
Const cRRepAccNo = 1
Const cRAssetCat = 2
Const cRMellonSec = 3
Const cRShpPar = 4
Const cRLocalMV = 5
Const cRPArxLocMV = 6


Sub MakeReport()
lngLastSectionRow = ActiveCell.row
Msgbox lngLastSectionRow
End Sub



-------------------

Don Guillett wrote:
As ALWAYS, post your code

Anyone can shine a light on this please?

[quoted text clipped - 11 lines]

M.


--
Message posted via http://www.officekb.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Option Explicit is ignored

I searched (in the whole project) but it is not found.
I have added the extremely simplified code above.


M.


RB Smissaert wrote:
Probably you have that variable declared globally (Public) or at module
level (Private). Do a search in your project.

RBS

Anyone can shine a light on this please?

[quoted text clipped - 11 lines]

M.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Option Explicit is ignored

Michiel - I copied and pasted your code (XL 2007) and got an error
message (Variable not defined) at:
lngLastSectionRow = ActiveCell.row

Which version are you using?

I have had some redim statements allowed without a dim in earlier
versions, which 2007 picked up.

Doug
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Option Explicit is ignored

I've seen the same thing. Sometimes it works, sometimes it doesn't. Most
of the time it works.

"Gary Keramidas" wrote:

i've seen this occasionally. code will run fine, then all of a sudden i get the
error that a variable is not defined. never found out what causes it, as it
doesn't happen very often.

--


Gary Keramidas
Excel 2003


"Michiel via OfficeKB.com" <u40062@uwe wrote in message
news:9e61b99e2ab81@uwe...
Anyone can shine a light on this please?

- I start my module with Option Explicit
- In options I also have Require Variable Declaration checked

In my code I use a variable that I did not declare in the Dim section.

Yet, I can still run my code......... without the compliler triggering me
that I forgot to declare the variable.

I do not want this, what should I do to make the option explicit enforced?

Thanks!

M.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1


.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Option Explicit is ignored

I use version 2003 11.8302 SP3

Dougaj4 wrote:
Which version are you using?


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200911/1

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Option Explicit is ignored

To all who were so kind to respond to my entry.
THANKS!

I think it is indeed the same what Gary and Barb experienced.
When I open a new workbook and drag over my VBA modules into that project and
run the code I do get the error. This seems like some bug to me.

So, THE SOLUTION / WORKAROUND:
- Move the modules to a new workbook
- Pray it will not happen again.

ML.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200911/1

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
Option Explicit [email protected] Excel Discussion (Misc queries) 5 April 30th 08 11:19 PM
option explicit Dave F Excel Discussion (Misc queries) 2 September 5th 06 02:46 PM
Option Explicit Piranha[_18_] Excel Programming 5 July 6th 05 04:18 AM
Option Commands (Option Explicit / Option Base etc) - Scope Alan Excel Programming 8 November 1st 04 02:22 AM
Option Explicit Grace[_4_] Excel Programming 6 June 12th 04 04:28 PM


All times are GMT +1. The time now is 10:25 PM.

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

About Us

"It's about Microsoft Excel"