ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListBox edit (https://www.excelbanter.com/excel-programming/376022-listbox-edit.html)

Geoff

ListBox edit
 
Hi
I have a 2 column listbox on a form and a textbox and I want to amend a
selected listbox item via the textbox entry.

When I select a value in the listbox for example:
OriginalValue = lboList.List(lboList.ListIndex, 1) = 6.14

And the value to be added (or subtracted) entered in the textbox = 12.00

Then I would expect this to work:

lboList.List(lboList.ListIndex, 1) = OriginalValue + 12.00

but it gives an error 'Could not set the list property. Permission denied.'
Indeed any value I try to set such as 'rubbish' gives an error.

What am I doing wrong?

T.I.A.

Geoff


Dave Peterson

ListBox edit
 
Did you populate that listbox via .rowsource?

If yes, try populating it some other way (.additem?).

Geoff wrote:

Hi
I have a 2 column listbox on a form and a textbox and I want to amend a
selected listbox item via the textbox entry.

When I select a value in the listbox for example:
OriginalValue = lboList.List(lboList.ListIndex, 1) = 6.14

And the value to be added (or subtracted) entered in the textbox = 12.00

Then I would expect this to work:

lboList.List(lboList.ListIndex, 1) = OriginalValue + 12.00

but it gives an error 'Could not set the list property. Permission denied.'
Indeed any value I try to set such as 'rubbish' gives an error.

What am I doing wrong?

T.I.A.

Geoff


--

Dave Peterson

Geoff

ListBox edit
 
Hi Dave
Yes I used rowsource.
I suppose another way might be to write the amended value back to the source
on the wsheet then use rowsource to refresh the listbox. I wonder if
creating an array of the source would suit. Either way it seems more code is
necessary.

Thanks

Geoff

"Dave Peterson" wrote:

Did you populate that listbox via .rowsource?

If yes, try populating it some other way (.additem?).

Geoff wrote:

Hi
I have a 2 column listbox on a form and a textbox and I want to amend a
selected listbox item via the textbox entry.

When I select a value in the listbox for example:
OriginalValue = lboList.List(lboList.ListIndex, 1) = 6.14

And the value to be added (or subtracted) entered in the textbox = 12.00

Then I would expect this to work:

lboList.List(lboList.ListIndex, 1) = OriginalValue + 12.00

but it gives an error 'Could not set the list property. Permission denied.'
Indeed any value I try to set such as 'rubbish' gives an error.

What am I doing wrong?

T.I.A.

Geoff


--

Dave Peterson


Geoff

ListBox edit
 
Hi Dave
Yes - just played around with putting the source data in a 2 column array
and populating the listbox with lboList.List().
Subsequent changes to original values are amended to the listbox via the
textbox entry and lboList.List(lboList.ListIndex, 1) = OriginalValue + 12.00
as I wanted.

Thanks for the help.

Geoff

"Geoff" wrote:

Hi Dave
Yes I used rowsource.
I suppose another way might be to write the amended value back to the source
on the wsheet then use rowsource to refresh the listbox. I wonder if
creating an array of the source would suit. Either way it seems more code is
necessary.

Thanks

Geoff

"Dave Peterson" wrote:

Did you populate that listbox via .rowsource?

If yes, try populating it some other way (.additem?).

Geoff wrote:

Hi
I have a 2 column listbox on a form and a textbox and I want to amend a
selected listbox item via the textbox entry.

When I select a value in the listbox for example:
OriginalValue = lboList.List(lboList.ListIndex, 1) = 6.14

And the value to be added (or subtracted) entered in the textbox = 12.00

Then I would expect this to work:

lboList.List(lboList.ListIndex, 1) = OriginalValue + 12.00

but it gives an error 'Could not set the list property. Permission denied.'
Indeed any value I try to set such as 'rubbish' gives an error.

What am I doing wrong?

T.I.A.

Geoff


--

Dave Peterson



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

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