Listbox - works 1/2 time

B

BigJimmer

Hi,

I have some option buttons (for now, Opt1 and Opt2), a listbox (ListBox1)
and a command button (Cmd1) on a worksheet. Here is the very basic code I
have reduced the option buttons to in trying to debug my issue...

Private Sub Opt1_Click()
ListBox1.Visible = False
Cmd1.Visible - False
End Sub

Private Sub Opt2_Click()
ListBox1.Visible = True
Cmd1.Visible = True
End Sub


When I click Opt1, the list box is not visible. When I then click Opt2, the
list box is visible and shows the info I expect. The problem is that I am
unable to select any rows in the list, or scroll down the list. The command
button works as coded (including error hanndling for no selection in the
list).

Then, I click Opt1 again, the list is hidden, followed by Opt2, the list is
now visible again. This time however, I can now select rows in the list, etc.

This pattern repeats, so that if click Opt1, then Opt2 again, I will not be
able to use the listbox, and then I can. I have checked that the list box
is always set to enabled, that the worksheet itself is not protected, and
looked for other settings that I thought might be causing this. I am using
Excel 2000.

Anyone know why this would happen?

Thanks!
 
D

Dave Peterson

Just a guess...

I think it's a display problem. Have you tried minimizing and maximizing the
application window--or scrolling up or down. Or toggling screenupdating off
then on in your code?

Sometimes, that kind of stuff helps.
 
B

BigJimmer

Application.ScreenUpdating was one of the first things I checked as I use
that frequently.

I just tried scrolling, and minimizing/maximizing the screen and neither of
those had any impact.
 
D

Dave Peterson

If you swap to a different application, does it help?

If you close (saving your file) and reopen, does it work ok?

If you close excel and reopen the file, does it work ok?

If you fiddle with the windows display settings (lowering the hardware
acceleration), does it work ok?

If you change video drivers--or test on a different pc, does it work ok?

That's right, I don't have a guess!
 
B

BigJimmer

Changing application, closing reopening the file/Excel, nothing was making a
difference. I didn't have the chance for trying other PCs yet, and an idea
occurred to me.

In my routine for displaying the list box, I now have the following , which
i don't like from a proramming perspective, though it has resolved the issue
until someone else can provde a better solution...

with ListBox1
.Visible = True
.Visible = False
.Visble = True
end with
 
D

Dave Peterson

You know what they call an ugly fix?

A Fix!!!

I'd use it <vbg>.
Changing application, closing reopening the file/Excel, nothing was making a
difference. I didn't have the chance for trying other PCs yet, and an idea
occurred to me.

In my routine for displaying the list box, I now have the following , which
i don't like from a proramming perspective, though it has resolved the issue
until someone else can provde a better solution...

with ListBox1
.Visible = True
.Visible = False
.Visble = True
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top