改一下代码: Sub 列表框显示() Dim i As Long Dim j As Long On Error Resume Next UserForm2.ListBox1.Clear UserForm2.ListBox1.ColumnCount = 8 With Sheets("结果显示") .Range("F2:F" & .[a65536].End(3).Row) = .Range("F2:F" & .[a65536].End(3).Row).Value '转化为数值 For i = 1 To .[a65536].End(3).Row UserForm2.ListBox1.AddItem For j = 1 To 8 If j = 2 Then UserForm2.ListBox1.List(UserForm2.ListBox1.ListCount - 1, j - 1) = Format(.Cells(i, j), "yyyy-m-d") Else UserForm2.ListBox1.List(UserForm2.ListBox1.ListCount - 1, j - 1) = .Cells(i, j) End If Next j Next i UserForm2.ListBox1.ColumnWidths = "52;52;42;100;25;28;26;40" End With End Sub
|