Declerations

  • Thread starter Thread starter mpeplow
  • Start date Start date
M

mpeplow

Is there any way to put this in one statement?

Dim FinalRow As Variant
FinalRow = ActiveSheet.Range("A65536").End(xlUp).Row
 
No. And declare it as Long, not Variant, you'll save memory and speed.

HTH. Best wishes Harald
 
Well...<g>
If you remove Option Explicit from your module then
"FinalRow = ActiveSheet.Range("A65536").End(xlUp).Row" will work and
the Dim statement is not required.
Of course, you will never want to let anybody see your code.<g>
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"mpeplow"
wrote in message

Is there any way to put this in one statement?
Dim FinalRow As Variant
FinalRow = ActiveSheet.Range("A65536").End(xlUp).Row
 
Sort of but it's a REALLY BAD IDEA. So long as you do not have "Option
Explicit" at the top of the code module you are not required to declare your
variables. VB will create varaibles on the fly for you. The variables created
are of type Variant. So you could just write (without the dim statement).

FinalRow = ActiveSheet.Range("A65536").End(xlUp).Row

When this line of code executes the compiler will create FinalRow for you as
a variable of type variant. I can not stress this enough that doing this is
an EXTREMELY BAD IDEA. DON'T DO IT. That being said it is possible.
 
thanks everyone

BTW: I remeber using Option Explicit way back when I was making VB6 six
apps and it's in all of my code. but I have forgotton what it does?
What does it do?

I'm guessing to force you to declare your variables which is a good
idea. And why is everyone so "ALL ABOUT" it.
 
You are exactly correct. Option Explicit forces you to declare all of your
variables. Not declaring variables is VERY VERY BAD programming... You can
actually get VB(A) to automatically place option explicit at the top of every
code module by choosing Tools -> Options -> Editor -> Require Variable
Declarations in the VBE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top