vba溢出错误

时间:2011-05-08 19:05:36

标签: excel-vba vba excel

尝试编译用户表单时出现溢出错误:

Nr Isikukood Eesnimi Perenimi Linn

1 38602110722 PriitBurmeisterJõgeva

Private Sub wisikukood_Change()
    Dim h As Range
    Set h = Range("tabel2")
    znimi.Value = h(wisikukood.Value, 3) + " " + h(wisikukood.Value, 4)
End Sub

该行是:znimi.Value = h(wisikukood.Value, 3) + " " + h(wisikukood.Value, 4)

我列表框中有wisikukood,表格中有firstname,而lastname有4个。

znimi - 从listbox wisikukood中选择值后需要填写文本框。

1 个答案:

答案 0 :(得分:0)

我不确定我是否完全理解您的特定问题,但假设您想使用11位数字来获取名称,那么使用VLOOKUP可能会有用:

Private Sub wisikukood_Change()
    Dim h As Range
    Set h = Range("tabel2")
    znimi.Value = WorksheetFunction.VLookUp(wisikukood.Value, h, 3, false) & " " & WorksheetFunction.VLookUp(wisikukood.Value, h, 4, false)
End Sub