View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default 2 Listbox's not working

I have to disagree, managing multiple forms is an unneeded complexity.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"macroplay" wrote in message
...
It seemed simpler to have each inoput form pop up separately so the user

is
stepped through each input requirement. Puting everything in one form

makes
things complex.

I'll look into it and see if it helps.

"Bob Phillips" wrote:

Why don't you put both listboxes on the same userform?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"macroplay" wrote in message
...
I have a macro with 2 listboxes that I want to use for selecting

values
from
2 lists. The main macro shows both lists sequentially and then uses

the 2
selected values to process data. Unfortunately when certain values in

the
first list are selected, the 2nd list box is not displayed but the

main
macro
code continues as if a val;ue from the 2nd list had been selected.

Below is the code in which the same form is used for both lists. I

tried
using two separate forms but that didn't help. If I uncomment the

msgbox
code
in the init routine, the lists work properly.

Column A has values a,b,c,d,e,blank and column b has values 1,2,3,

blank

======================

Private Sub ListBox1_Click()
poolName = ListBox1.Value
Unload Me
End Sub

Private Sub userform_initialize()

'MsgBox "form 1 init"

Windows("InvoiceMacro.xls").Activate

Sheets("Lists").Select

If listnum = 1 Then Range("a1").Select Else Range("b1").Select

Do Until ActiveCell.Value = ""
ListBox1.AddItem (ActiveCell.Value)
ActiveCell.Offset(1, 0).Select
Loop

End Sub
Private Sub UserForm_Click()

End Sub


++++ main macro

Sub doboth()

listnum = 1
frmListbox1.Show


listnum = 2
frmListbox1.Show


End Sub