Skip to main content
1-Visitor
March 9, 2011
Solved

Can't save dependent Listbox

  • March 9, 2011
  • 7 replies
  • 5332 views

When I close the worksheet I can not save a listbox selection that is dependent on a previous listbox selection. The first listbox I was able to save the selection using the Metadata , but I could not figure out how to get it to work with the second list box.

Best answer by RichardJ

I tried to implement the code you provided and its giving me some problems. The second listbox will not update now when I change the selection in the first listbox.

The code in the body of the script (i.e. outside of any of the subrountines) only gets executed once, when the worksheet is loaded. That is why setting the OnLoad flag works! The only exception to that rule is that if you edit the script, when you exit the editor the code in the body of the script is executed.

Also the sheet is acting really slow when I change a selection in the first listbox.

I fixed that. Also in the original worksheet I posted, so I have attached another version.

7 replies

19-Tanzanite
March 9, 2011

I don't see any code in the second listbox that attempts to save the state. I'll assume you tried putting some in? Did you use the same name for the metadata item? Because that will not work.

I see you based your script on the script written at PTC. Unfortunately, that script is very badly written. The attached uses a much improved script.

The start and stop routines are obsolete, and have been for at least a decade. They no longer serve any purpose. You should ignore them.

SteveA1-VisitorAuthor
1-Visitor
March 10, 2011

Yea I didn't include the code in that second listbox because I couldn't get it to work.

I tried to implement the code you provided and its giving me some problems. The second listbox will not update now when I change the selection in the first listbox. Also the sheet is acting really slow when I change a selection in the first listbox. I have attached the updated worksheet.

RichardJ19-TanzaniteAnswer
19-Tanzanite
March 10, 2011

I tried to implement the code you provided and its giving me some problems. The second listbox will not update now when I change the selection in the first listbox.

The code in the body of the script (i.e. outside of any of the subrountines) only gets executed once, when the worksheet is loaded. That is why setting the OnLoad flag works! The only exception to that rule is that if you edit the script, when you exit the editor the code in the body of the script is executed.

Also the sheet is acting really slow when I change a selection in the first listbox.

I fixed that. Also in the original worksheet I posted, so I have attached another version.