Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Help with Emptying a Collection

  Asked By: Viveka    Date: Aug 27    Category: MS Office    Views: 583
  

What is the easist way to empty a collection to allow for more/new
items to be added?

Dim CheckEmpty As New Collection

Sub CollectionEmptyTry()
Dim Obj As String
Obj = Range("P17").Value

If Cells(1, 1) <> "" Then
CheckEmpty.Add Obj

If CheckEmpty.Count > 20 Then
CheckEmpty = Empty
End If

End Sub

This does not work but it shows what i am trying to accomplish?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Noel Peterson     Answered On: Aug 27

Not sure but can't you set the collection  to nothing and then re Dim
it?

 
Answer #2    Answered By: Iqbal Bashara     Answered On: Aug 27

May be this helps!

set CheckEmpty = nothing

 
Answer #3    Answered By: Bryson Smith     Answered On: Aug 27

I tried this and received this error message:

Run-time error '424':

Object Required

The code I used:

Sub CollectionEmptyTry()
Dim Obj As String
Obj = Range("P17").Value

If Cells(1, 1) <> "" Then
CheckEmpty.Add Obj
End If

Set CheckEmpty = Empty 'generates error

MsgBox CheckEmpty.Count

End Sub

 
Answer #4    Answered By: Minnie Romero     Answered On: Aug 27

Yo...

Try ...

Set CheckEmpty = Nothing

 
Didn't find what you were looking for? Find more on Help with Emptying a Collection Or get search suggestion and latest updates.




Tagged: