|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
正常的显示是这样的,如图:
但是当数据以后一条时,就会这样:
我的代码是这样的:
Private Sub ComboBox1_Change()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sql As String, arr
On Error Resume Next
cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName
If VBA.Len(ComboBox1.Value) <> 0 Then
sql = "select 产品名称,统一售价,代码 from [产品设置$] where 类别 = '" & ComboBox1.Value & "'"
ListBox1.Clear
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = 135 & ";" & 75 & ";" & 75 & ""
arr = cnn.Execute(sql).GetRows
ListBox1.List = WorksheetFunction.Transpose(arr)
cnn.Close
Set cnn = Nothing
End If
End Sub
|
|