Thread: Good Practice
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ardus Petus Ardus Petus is offline
external usenet poster
 
Posts: 718
Default Good Practice

This is precisely what I thought.

Thanks,
--
AP

"Chip Pearson" a écrit dans le message de
...
If the object is declared within the sub, there is no reason to
set it to Nothing at the end of the sub. VBA will destroy the
object when the sub ends.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Ardus Petus" wrote in message
...
In this and other Excel NGs, I see quite often VBA lines like:

sub Foo()
dim myRng as Range
dim myRS as ADODB.Recordset
...
set myRng = Nothing
set myRS = Nothing
End Sub

Is this setting objects to Nothing really useful for local
variables that
will be automatically destroyed at the end of the Sub.

TIA

--
AP