Excel User Form Create a data entry form | Display data in a List Box with more than 10 columns

Опубликовано: 01 Сентябрь 2026
на канале: รูนเมืองตรัง
3,670
73

#listboxmore10column #vbalistboxmore10column

-----------------------------------------------------
Sub showdata()
Dim i As Integer
Dim datarow(1 To 100000, 1 To 11) 'Set array variable'
For i = 1 To Sheet4.Range("A100000").End(xlUp).Row 'Number of rows in sheet'
c = 11 '¨Ó¹Ç¹ column'

For x = 1 To c
datarow(i, x) = Sheet4.Cells(i, x) 'Store all data into array variable named datarow'

Next x

Next i
Me.ListBox1.ColumnWidths = "70,200,50,60,90,100,200,150,200,100,130"
Me.ListBox1.List = datarow
Me.ListBox1.ColumnCount = c
' Me.ListBox1.TextAlign = fmTextAlignCenter 'Center align
Me.ListBox1.Selected(0) = True 'Select the first row, there will be a blue bar
End Sub