Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
List Box in User Form filled by Range
I have a range of data on a worksheet and on the user form I have is a list
box, I want the user form to open and have the range of data added to the list box, how can this be done? The range will change when data is added... I have this code so far which opens the user form and shows me a blank list box, how can it be filled? Jez Option Explicit Dim adoRS As New ADODB.Recordset Sub addToList(rs As ADODB.Recordset, strShtName As String) Dim lngJ As Long For lngJ = 0 To rs.Fields.Count - 1 Sheets("AllActions").Cells(1, lngJ + 1) = rs.Fields(lngJ).Name Next Sheets("AllActions").Range("A2").CopyFromRecordset rs If rs.RecordCount = 1 Then If rs.RecordCount = 1 Then Me.lstActions.RowSource = "AllActions!A2:J" + CStr(findLastRow(Sheets("AllActions").Range("A2"), "") + 1) Me.lstActions.ColumnCount = rs.Fields.Count Me.lstActions.ColumnHeads = True Else Me.lstActions.RowSource = "AllActions!A2:J" + CStr(findLastRow(Sheets("AllActions").Range("A2"), "")) Me.lstActions.ColumnCount = rs.Fields.Count Me.lstActions.ColumnHeads = True End If Else Me.lstActions.RowSource = "AllActions!A2:J2" Me.lstActions.ColumnCount = rs.Fields.Count Me.lstActions.ColumnHeads = True End If Set adoRS = rs End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
list box on user form | Excel Programming | |||
Searching in a user form / List box | Excel Programming | |||
How to: User Form to assign a user defined range to a macro variab | Excel Programming | |||
User Form List Box | Excel Programming | |||
User Form / List Box | Excel Programming |