|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub UserForm_Initialize()
Dim i As Integer
Dim Col As ColumnHeader, Itm As ListItem
With ListView1
.View = lvwReport
.Gridlines = True
.FullRowSelect = True
.ColumnHeaders.Add , , "NO", 0 '第一列,隱藏,用於記錄行號
End With
For i = 2 To Sheet2.Range("IV2").End(xlToLeft).Column
Set Col = ListView1.ColumnHeaders.Add()
Col.Text = Sheet2.Cells(1, i)
Next
Call XianShi
End Sub
Private Sub XianShi()
Dim i As Integer, j As Integer
ListView1.ListItems.Clear
With Sheets("數據庫")
For i = 2 To .Range("A65536").End(xlUp).Row
Set Itm = ListView1.ListItems.Add()
Itm.Text = i '記錄行號
For j = 2 To .Range("IV2").End(xlToLeft).Column
Itm.SubItems(j - 1) = .Cells(i, j)
Next
Next
End With
End Sub
代碼要怎樣修改呢??
|
|