Skip to main content
edited body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize'Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    'Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 
added 3 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 
added 15 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In reference tothe sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if it is in fact good practice, why? Else, doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In reference to sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, if it is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 

I've noticed that some members of the Stack Overflow community will use Set Object = Nothing in closing procedures. I was able to find why this is useful for instances of Access, but no answer has been satisfying when it comes to doing this for Excel, so my question is What are the benefits of setting objects to Nothing in VBA?

In the sample code below, is setting my objects ws and Test equal to Nothing a waste of space? Else, doing so is in fact good practice, why?

Dim ws as Worksheet
Dim Test as Range

Set ws = Sheets(“Sheet1”)
Set Test = ws.Range(“A1”)

    ‘Utilize Test variable (copy, paste, etc)

Set Test = Nothing
Set ws = Nothing

Exit Sub 
edited tags
Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading
deleted 1 character in body; edited body; added 1 character in body; added 1 character in body; added 3 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading
deleted 2189 characters in body; added 15 characters in body; added 43 characters in body; added 32 characters in body; added 1 character in body; added 15 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading
edited title
Link
Patrick Honorez
  • 25.4k
  • 12
  • 99
  • 164
Loading
added 22 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading
added [excel] to 23464 questions - Shog9 (Id=811)
Link
Loading
added 75 characters in body
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading
Source Link
urdearboy
  • 14.6k
  • 6
  • 37
  • 66
Loading