我有下拉需要从 lookupDept 工作簿上的两列中提取信息并合并。例如我有:
deptCode deptName
BS Business School
CD Design and Technology
CG Chemical Engineering
CM Chemistry
CO Computer Science
我已经设法解决了关于从两个电子表格列中提取信息以在组合框中使用的问题。但不幸的是,组合框列表现在看起来像这样:
BS
CD
CG
CM
Business School
Design and Technology
Chemical Engineering
Chemistry
当我希望它看起来像这样时:
BS Business School
CD Design and Technology
CG Chemical Engineering
CM Chemistry
这需要合并两列信息(列已命名为deptCode和deptName),但我不太确定如何完成它。这是我迄今为止尝试过的,来自两列的代码列表信息,而不是合并它们:
Private Sub UserForm_Initialize()
Dim c_deptCode As Range
Dim c_deptName As Range
Dim ws_dept As Worksheet
Set ws_dept = Worksheets("lookupDept")
For Each c_deptCode In ws_dept.Range("deptCode")
With Me.cbo_deptCode
.AddItem c_deptCode.Value
.List(.ListCount - 1, 1) = c_deptCode.Offset(0, 1).Value
End With
Next c_deptCode
For Each c_deptName In ws_dept.Range("deptName")
With Me.cbo_deptCode
.AddItem c_deptName.Value
End With
Next c_deptName
End Sub