Clear Method not working for a ListBox clear

S

scott56hannah

Hi,

I have the following code and I am trying to clear the values in a ListBox...

If ActiveCell.Offset(i, 0) = "" Then
VendorEntry_1280x1024.RuleListBox.Clear
Exit Sub
End If

When the routine is executed it returns the following error message

Run-time error '-2147467259 (80004005)

Unspecified error.

The routine does not continue or recover...can anyone assist with this one ?

Thanks
Scott
 
P

paul.robinson

hi
Works for me when I run it from a command button on the userform.
Where are you running this code from? Is the userform visible? Is it
loaded?

regards
Paul
 
S

scott56hannah

Paul,

Yes the form is visible and loaded....I am running the code from a "Refresh"
button on the form...it is not working for me....

Interestingly it goes through the initial call when the form is first
initialised and it runs this step....then after the list box is populated
with values for the first time and then I try to refresh it returns this error

Scott
 
P

paul.robinson

Hi
I can't reproduce your problem given the code snippet you posted.
Perhaps it is another part of the code causing the problem?
Paul
 
S

scott56hannah

Paul,

Have now found the problem....for the Listbox I was assigning a Range value
for the values to the RowSource property. If I clear that value by assigning
a "" rather than use the .Clear action it clears all values from the
list.....looking at some doco on list boxes if you assign a range you cannot
delete or add items using the actions you must change the RowSource
assignment...

Thanks for your help

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top