LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default dynamically created listbox

Hi,
I have a problem using events with a listbox.

I have a first listbox, named "listbox1", and I want to display a second
listbox "listbox3" when the user selects a value of the first listbox. I
thought I could use the change or afterupdate events, placed in the userform
module, but nothing happends when an item of the first listbox is selected.

Does it have something to do with the fact that both of my listboxes are
created dynamically?

Here is my code:

'creation of listbox1
Set champ =
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Add("Forms.ListBox.1", "ListBox" & nb)
champ.Visible = False

......

'display
nomchamp =
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nb - 4).Name
For i = 0 To UserFormCreerRequete.ListBoxChamps.ListCount - 1
If UserFormCreerRequete.ListBoxChamps.Selected(i) = True Then

UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomchamp).AddItem UserFormCreerRequete.ListBoxChamps.List(i)
End If
Next i

With
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomchamp)
.Height = 16
.Left = leftpremieroptionbouton + 70
.Top = toppremieroptionbouton '+...
.Width = 90
.Visible = True
End With

the change event:

Private Sub ListBox1_Change()

For i = 0 To
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomchamp).ListCount - 1
If
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomchamp).Selected(i) = True Then 'on a la colonneselectionnee

Set recherche =
Cells.Find(What:=UserFormCreerRequete.MultiPage1.o ngletselection.Controls.Item(nomchamp).Selected(i) , After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

colonneSelectionnee = recherche.Column
feuilleSelectionnnee = recherche.Sheet
lastline =
ThisWorkbook.Sheets(feuilleSelectionnnee).Cells(65 536,
colonneSelectionnee).End(xlUp).Row
For j = 2 To lastline

UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomvaleur).AddItem Cells(j, colonneSelectionnee)
Next j

End If
Next i


nomvaleur =
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nb - 2).Name




With
UserFormCreerRequete.MultiPage1.ongletselection.Co ntrols.Item(nomvaleur)
.Height = 16
.Left = leftpremieroptionbouton + 225
.Top = toppremieroptionbouton '+...
.Width = 90
.Visible = True
End With


End Sub

 
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
Assign click functionality to dynamically created textboxes? Ouka[_17_] Excel Programming 3 August 25th 05 03:15 AM
Scaling a chart that has been dynamically created in vb Mark Charts and Charting in Excel 3 May 27th 05 08:16 PM
Back color of dynamically-created buttons simon Excel Programming 2 April 11th 05 11:44 AM
Assign macros to dynamically created form elements Joepy Excel Programming 4 March 3rd 04 09:03 PM


All times are GMT +1. The time now is 09:47 PM.

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

About Us

"It's about Microsoft Excel"