ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Declerations (https://www.excelbanter.com/excel-programming/367581-declerations.html)

mpeplow[_15_]

Declerations
 

Is there any way to put this in one statement?

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


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555


Harald Staff

Declerations
 
No. And declare it as Long, not Variant, you'll save memory and speed.

HTH. Best wishes Harald


"mpeplow" skrev i
melding ...

Is there any way to put this in one statement?

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


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile:

http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555




Tim Williams

Declerations
 
VBA doesn't support assignment as part of a declaration.

So no, not really.

--
Tim Williams
Palo Alto, CA


"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


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555




Jim Cone

Declerations
 
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
--
mpeplow


Jim Thomlinson

Declerations
 
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.
--
HTH...

Jim Thomlinson


"mpeplow" wrote:


Is there any way to put this in one statement?

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


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555



mpeplow[_16_]

Declerations
 

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.


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555


Jim Thomlinson

Declerations
 
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.
--
HTH...

Jim Thomlinson


"mpeplow" wrote:


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.


--
mpeplow
------------------------------------------------------------------------
mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812
View this thread: http://www.excelforum.com/showthread...hreadid=562555




All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com