首页 > Excel专区 > Excel函数 >

excel VBA LISTBOX初始化代码

Excel函数 2023-01-13

Private Sub UserForm_Initialize()
Dim lsb As Worksheet
Set lsb = Sheets("临时表")
X = lsb.[a65536].End(3).Row
With ListBox1
.ColumnCount = 7 ‘设置7列
.ColumnWidths = "30,70,70,70,70,70,50" ‘设置每列宽度

.ColumnHeads = True ‘是否有标题表头
.RowSource = lsb.Range("a2:g" & X).Address(External:=True) ‘设置内容
End With
End Sub


Copyright © 2016-2023 office学习教程网 office.tqzw.net.cn. All Rights Reserved.