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: 5
Default Listbox

Hi all.
I have follow situation:
- Sheet Customers
A B C D E
1 Id Name Address City Phone
2 1 Rose 7, Red St. Paris 123456
3 2 Lisa 2, Blue Av. Milan 789012
4 3 Tom 5, Pink St. Rome 452134
5 4 Sam 3, Green St. London 327812
etc.

I have UserForm1 with following controls:
- Listbox1 ( alphabet letters)
- Listbox2 ( name)
- Textbox1 (Address)
- Textbox2 (City)
- Textbox3 (Phone)

and this code:

Option Explicit

Private Sub Userform_Activate()
Worksheets("Customers").Activate
End Sub

Private Sub UserForm_Initialize()
m_FillAlphabet ListBox1
End Sub

Private Sub m_FillAlphabet(MiaLista As MSForms.ListBox)
' Populate listbox1 with alphabet letters (Capital)
Dim intIndice As Integer, intalfa As Variant
Const CAPITAL = 65
intalfa = CAPITAL

MiaLista.Clear
For intIndice = 1 To 26
MiaLista.AddItem Chr(intalfa)
intalfa = intalfa + 1
Next
End Sub

Private Sub m_FillNames(MatchNome As String, MiaLista As MSForms.ListBox)
' Populate listbox2 with Names corresponding to the selected letter of
alphabet
Dim lngRiga As Long
Dim strLettera As String

strLettera = Left(MatchNome, 1)
MiaLista.Clear
lngRiga = 2
With Worksheets("Customers")
Do While .Cells(lngRiga, 1) < ""
If StrComp(strLettera, Left(.Cells(lngRiga, 2), 1), _
vbTextCompare) = 0 Then
MiaLista.AddItem .Cells(lngRiga, 2)
End If
lngRiga = lngRiga + 1
Loop
End With
End Sub

Private Sub ListBox1_Change()
' populate Listbox2 with Names and clear Textboxes
m_FillNames ListBox1.List(ListBox1.ListIndex), ListBox2
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub

Private Sub ListBox2_Click() ' here need your help
TextBox1.ControlSource = ? code for Address
TextBox2.ControlSource = " for City
TextBox3.ControlSource = " for phone
End Sub

Thanks for any help.
Regards, John.


 
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
Listbox 2 takes the value of Listbox 1 Illya Teideman Excel Discussion (Misc queries) 3 April 10th 07 03:20 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Listbox B if LIstbox A equals Kim K Excel Discussion (Misc queries) 2 October 31st 06 07:03 PM
ListBox (maybe?) ... If so, how? Ken Excel Discussion (Misc queries) 3 December 15th 04 10:16 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 07:25 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"