Listbox selection to fill Textboxes

autigers

Board Regular
Joined
Oct 9, 2005
Messages
139
After searching through and trying the various codes that were in this forum ... I have come up short ... (Shutup) :confused:
I have a listbox on userform that populates data from the code below
what I am trying to achieve is that when I select a line in the listbox, I wish to have the 11 textboxes that are under the listbox populate with the data that relates to the list box for editing purposes ....
As always your assistance is greatly appreciated ....
Code:
Private Sub UserForm_Initialize()
Dim a, i As Long, ii As Integer, n As Long
Dim ListAry()
With Sheets("Waves").Range("A2").CurrentRegion
    a = .Resize(, 13).Value
End With
For i = 2 To UBound(a, 1)
    If IsEmpty(a(i, 13)) Then
        n = n + 1
        ReDim Preserve ListAry(1 To 13, 1 To n)
        For ii = LBound(a, 2) To UBound(a, 2)
            If ii = 2 Then
                If Not IsEmpty(a(i, ii)) Then
                    ListAry(ii, n) = CStr(Format(a(i, ii), "hh:mm AM/PM"))
                End If
            Else
                ListAry(ii, n) = a(i, ii)
            End If
        Next
        ListAry(13, n) = i
    End If
Next
Erase a
If n = 0 Then Me.ListBox1.Clear: Exit Sub
With Me.ListBox1
    .ColumnCount = 12
    .ColumnWidths = "0;52;54;54;54;54;54;54;54;54;54;40;10"
    .Column = ListAry
 End With
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
jindon said:
OOps, sorry for that.

And glad that you've found it out!

good job

Yes it can get a bit involved some nights on this ....
No need for sorry's though .... You have been a tremendous help with this major project .....
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top