Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 2 Listbox's not working

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 2 Listbox's not working

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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default 2 Listbox's not working

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






  #4   Report Post  
Posted to microsoft.public.excel.programming
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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
Listbox's and retaining data when closing eklarsen[_6_] Excel Programming 0 May 7th 04 05:25 AM
LISTBOX'S GREGORY Excel Programming 3 December 1st 03 01:50 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"