Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
raj raj is offline
external usenet poster
 
Posts: 32
Default Set variable = nothing?

Just a quick verification...

If one were to use the following code line:

Set xFind = Range(xColumn).Find("Total Equities")

Or for that matter, anytime the "Set" command is used,
shouldn't one always at some point later set the variable
equal to nothing?

For example,

Set xFind = Nothing

Thanks for your input.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Set variable = nothing?

If it is a local variable and the routine ends, it is cleaned up anyway
because it goes out of scope. So it isn't necessary/essential.

--
Regards,
Tom Ogilvy

"raj" wrote in message
...
Just a quick verification...

If one were to use the following code line:

Set xFind = Range(xColumn).Find("Total Equities")

Or for that matter, anytime the "Set" command is used,
shouldn't one always at some point later set the variable
equal to nothing?

For example,

Set xFind = Nothing

Thanks for your input.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Set variable = nothing?

Raj,

A very interesting question, with differing opinions.

The obvious answer is yes, of course you should, otherwise memory is tied up
unnecessarily. However, Matthew Curland, who is a Microsoft Developer who
works on VB, whereby he scorned the practice as totally unnecessary,
breaking program flow, and adding to the size of your code.

I had an exchange of views with Dick Kusleika in these groups on the topic,
and my conclusion was that I am ready to take the chance of not setting to
Nothing, unless I want to clear it early in the code, use it as a
documentation aid to say that this object is no longer required. But .... if
I forget and set it to nothing, not something to lose sleep over.

If you want to read that exchange, try http://tinyurl.com/sr3o


HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"raj" wrote in message
...
Just a quick verification...

If one were to use the following code line:

Set xFind = Range(xColumn).Find("Total Equities")

Or for that matter, anytime the "Set" command is used,
shouldn't one always at some point later set the variable
equal to nothing?

For example,

Set xFind = Nothing

Thanks for your input.



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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
How to graph x-variable versus y-variable in Excel ? Mojjara New Users to Excel 3 April 2nd 09 05:38 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


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