从两个范围中选择取决于从组合框中选择

时间:2018-04-28 10:21:28

标签: vba range

我想添加combobox3(从两个项目中选择),当我从中选择项目时,更改combobox2中显示的行源,然后我从combobox2中选择项目以使用下面的代码获取其数据

Private Sub ComboBox2_Change()
On Error Resume Next
Dim myRange As Range
Set myRange = Worksheets("cash").Range("BF:BH")
Price.Value = ""
    On Error Resume Next
Price.Value = Application.WorksheetFunction.VLookup(ComboBox2.Value, myRange, 2, 0)
unitplace.Value = Application.WorksheetFunction.VLookup(ComboBox2.Value, myRange, 3, 0)
Price.Value = Format(Price, "#,###,##.00")
End Sub

1 个答案:

答案 0 :(得分:0)

看起来像你之后:

Private Sub ComboBox3_Change()
    Me.ComboBox2.LinkedCell = "BM:BO"
End Sub