Edit Multi-Column List Box

User avatar
HansV
Administrator
Posts: 78642
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Edit Multi-Column List Box

Post by HansV »

So what exactly is your question?
Best wishes,
Hans

micklep
NewLounger
Posts: 5
Joined: 11 May 2013, 17:13

Re: Edit Multi-Column List Box

Post by micklep »

The line that writes "yes" to the active sheet is deselecting items in the list box.

User avatar
HansV
Administrator
Posts: 78642
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Edit Multi-Column List Box

Post by HansV »

I see no reason why writing "Yes" in a cell would deselect items in a list box. Can you attach a small sample workbook demonstrating the problem? (Max. file size 250 KB).
Thanks in advance.
Best wishes,
Hans

micklep
NewLounger
Posts: 5
Joined: 11 May 2013, 17:13

Re: Edit Multi-Column List Box

Post by micklep »

Hi, Please see attached. I have only includes the parts of the program in question to save on file size.
I have included a comment block within the code, the problem line is within that block.
Run the sheet from "Home" without touching the code first and select two or more items then click print. I have replaced the print code with a msgbox to save your ink lol
Once you see how it should work, uncomment the problem line and repeat. It should make sense then.
Thanks a million!
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78642
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Edit Multi-Column List Box

Post by HansV »

Thanks! The reason is that the list box has a range as row source. The moment you change a value in that range, the list box is automatically refreshed, and this causes all items to be deselected.
The easiest workaround is to use the AddItem method to populate the list box instead of setting the row source.
See the attached version.
Test System.xlsm
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

micklep
NewLounger
Posts: 5
Joined: 11 May 2013, 17:13

Re: Edit Multi-Column List Box

Post by micklep »

you legend!!!!! THANK YOU!!!!!!!!