【问题标题】:Removing empty rows of combobox in excel - VBA删除excel中组合框的空行 - VBA
【发布时间】:2018-10-08 03:50:29
【问题描述】:
此代码显示 Sheet1 的所有单元格列 A(即使是空值)。
最后一行在combobox1中有值的解决方法是什么> (并在末尾删除 empaty 值)?
Private Sub UserForm_Initialize()
ComboBox1.List = Sheets("Sheet1").Range("A:A").Value
End Sub
【问题讨论】:
标签:
excel
vba
combobox
userform
【解决方案1】:
试试这个:
With Sheets("Sheet1")
ComboBox1.List = .Range(.Range("A1"), .Cells(.Rows.count, 1).End(xlUp)).Value
End With
【解决方案2】:
Private Sub UserForm_Initialize()
With Sheets("Sheet1")
ComboBox1.List = .Range(.Range("A1"), .Cells(.Rows.Count,1).End(xlUp)).Value
End With
End Sub