ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear Method not working for a ListBox clear (https://www.excelbanter.com/excel-programming/406090-clear-method-not-working-listbox-clear.html)

scott56hannah

Clear Method not working for a ListBox clear
 
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

[email protected]

Clear Method not working for a ListBox clear
 
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

On Feb 14, 8:22*am, scott56hannah
wrote:
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



scott56hannah

Clear Method not working for a ListBox clear
 
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

" wrote:

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

On Feb 14, 8:22 am, scott56hannah
wrote:
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




[email protected]

Clear Method not working for a ListBox clear
 
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

On Feb 14, 12:28*pm, scott56hannah
wrote:
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



" wrote:
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


On Feb 14, 8:22 am, scott56hannah
wrote:
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- Hide quoted text -


- Show quoted text -



scott56hannah

Clear Method not working for a ListBox clear
 
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

" wrote:

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

On Feb 14, 12:28 pm, scott56hannah
wrote:
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



" wrote:
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


On Feb 14, 8:22 am, scott56hannah
wrote:
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- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com