Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Exchanging Values Between Two ListBoxes.
Hello,
I have two listboxes on a form, one which holds a master list and the other the selections I have made. Basically, as I click on values from the master list I want it to disappear from the master and appear in the selected list (and vice versa). Initially, the master will be fully populated, but eventually some of the selections will be moved over to the selected list. Currently I do this by reading from a global list in a hidden sheet and, depending on which listbox the entry should be in, populate the correct listbox. These values are written to a named sheet range each time (as this helps greatly with sorting) by capturing the _Click event on both of the listboxes. My first problem is this; on the first click the _Click routine effectively fires twice and therefore the entry underneath the one selected moves across to the other listbox as well as the one selected. This only happens the first time I click on the listbox as all subsequent clicks only move the line selected. I've tried to capture the first time it initialises the _Click by setting a status flag to False when the form loads and using an IF statement in the _Click routine to prevent it running the first time, but this means that all subsequent clicks need to be performed twice to get it to run. Any help would be much appreciated on this one as both workarounds don't produce satisfactory results. I can post code if you think it'll help. My second problem also involves these listboxes, but is more of an annoyance. Assuming that the above problem was solved, I'd like to be able to select an entry on ListBoxA, watch it jump over to ListBoxB and be able to select the entry below on ListBoxA to do the same. However, when I click to move an item the item below is automatically highlighted (in blue) and is unselectable, which means I have to click a different item, then the one I want and finally unselect the other one from the other list which might remove two entries if I can't solve the problem above! If anyone knows how to unhighlight on the _Click event, I'd appreciate it. I have tried the UserForm.ListBox1.Selected(i) = True/False, but that didn't seem to do anything. Is there a way of refreshing ListBoxes without having to reinitialise the form each time? Cheers, Ross. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exchanging information | Excel Worksheet Functions | |||
exchanging rows | Excel Worksheet Functions | |||
Exchanging text between two cells | Excel Programming | |||
exchanging values amoung sheets | Excel Worksheet Functions | |||
exchanging X and Y in a plot | Excel Programming |