Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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


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
Public Declerations Shawn Excel Programming 5 July 24th 05 11:53 PM


All times are GMT +1. The time now is 08:06 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"