Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
How to graph x-variable versus y-variable in Excel ? | New Users to Excel | |||
variable height variable width stacked bar charts | Charts and Charting in Excel | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions |