การแสดงผลของ ListBox
Posted: Fri Apr 18, 2014 5:12 pm
คือว่าผมต้องการเขียนโค้ดให้แสดงผลใน บรรทัดเดียวกัน
แต่ไม่รู้วิธี รบกวนด้วยครับ
_ขอบคุณครับ_
แต่ไม่รู้วิธี รบกวนด้วยครับ
_ขอบคุณครับ_
คลังคำตอบแห่งความรู้จากคนไทย เพื่อโลกที่ต้องการเข้าใจในสิ่งเล็ก ๆ อย่างลึกซึ้ง
https://www.snasui.com/
Code: Select all
Dim Y As Integer,Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Sheet1.LB1
.Clear
.ColumnCount = 2
For Y = 0 To LR - 1
.AddItem
.Column(0, Y) = Cells(Y + 1, 1)
.Column(1, Y) = Cells(Y + 1, 2)
Next
End With
Code: Select all
Private Sub CommandButton1_Click()
Dim Y As Integer, LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Sheet1.LB1
.Clear
.ColumnCount = 3
For Y = 1 To LR
For i = 0 To 2
.AddItem
.Column(i, Y - 1) = Cells(Y, i + 1)
Next i
Next Y
End With
End SubCode: Select all
Private Sub CommandButton1_Click()
Dim Y As Integer: Dim LR As Long
Dim i As Integer
LR = Range("A" & Rows.Count).End(xlUp).Row
With Sheet1.LB1
.Clear
.ColumnCount = 3
.ColumnWidths = "20;130;30"
For Y = 1 To LR
If Cells(Y, 2).Value = "A" Then
.AddItem
.Column(0, i) = Cells(Y, 1)
.Column(1, i) = Cells(Y, 2)
.Column(2, i) = Cells(Y, 3)
i = i + 1
End If
Next
End With
End Sub