Stoppoing ComboBox Change Event from firing when Multipage changes

G

GH

I have a Userform with two-page Multipage control. Multipage1 contains
a combobox (ComboBox1) tied to a excel file (File1)opened in the
background during form initialization. ComboBox1 lists the sheets in
File1. Multipage1 also contains a listbox (ListBox1) that displays
data on the sheet selected in ComboBox1. Updating the contents of
ListBox1 is controled via the "Change" event for ComboBox1. Works like
a champ.

Multipage2 also contains a listbox (Listbox2) that displays data from a
separate excel file (File2). To populate ListBox2, the user identifies
which excel file to open via a command button using
Application.GetOpenFilename. The identifed File2 is then opened in the
background. So both File1 and File2 are open in the background.

And now the problem. If the user has selected a sheet in ComboBox1 and
then proceeds to Multipage2 to select File2 such that ListBox2 is
populated, the "Change" event code tied to ComboBox1 also fires because
changing pages is a Change event for ComboBox1. The Change event code
crashes as the code is attempting to execute on File2 and not File1. I
am fairly certain that this is the issue as no error occurs if no sheet
has been selected in ComboBox1 before the user proceeds to Multipage2.

How can I trap this? I tried changing the event tied to Combobox1 from
"Change" to "AfterUpdate" but ListBox1 would not update until I took
the focus off ComboBox1.

Thanks in Advance.

GH
 

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