View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default list box selection?

Hi
In your UserForm_Initialise() sub insert

Me.ListBox1.Rowsource = Sheet1!A1:A5

to populate Listbox1 with data in range A1 to A5 on sheet1.

regards
Paul

Hazel wrote:

Hi All

I'm using a userform populated from the Row Source on the first sheet - I
have used a snippet of code off this forum to change the sheet in the
workbook thats OK how do I then populate the list box from the new sheet. Its
only a simple form so have included all the code being used below.

Option Explicit


Private Sub UserForm_Initialise()



Range(Me.Lb1.RowSource).Resize(1, 1).Offset(Me.Lb1.ListIndex, 3) =
Me.Tb1.Value



End Sub
Private Sub Add1_Click()
If Me.Lb1.ListIndex -1 Then
Range(Me.Lb1.RowSource).Resize(1, 1).Offset(Me.Lb1.ListIndex, 3) =
Me.Tb1.Value
End If
End Sub

Private Sub Lb1_Click()
Tb1.Value = ""
End Sub

Private Sub UserForm_Activate()
Com1.Value = "Select Members Sheet"
Com1.AddItem "JBloggs"
Com1.AddItem "ASmith"

End Sub

Private Sub Com1_Click()
If Com1.ListIndex < -1 Then
Worksheets(Com1.Value).Select
End If
End Sub


--
Many thanks

hazel