删除 excel 中组合框的空行 - VBA

Removing empty rows of combobox in excel - VBA

此代码显示 Sheet1 的所有单元格列 A即使末尾为空值 ). 显示到 最后一行 的解决方案是什么 value in combobox1并在结尾中删除empaty值)?

Private Sub UserForm_Initialize()
ComboBox1.List = Sheets("Sheet1").Range("A:A").Value
End Sub

试试这个:

With Sheets("Sheet1")
    ComboBox1.List = .Range(.Range("A1"), .Cells(.Rows.count, 1).End(xlUp)).Value
End With
Private Sub UserForm_Initialize()
With Sheets("Sheet1")
  ComboBox1.List = .Range(.Range("A1"), .Cells(.Rows.Count,1).End(xlUp)).Value
End With
End Sub