计算机函数公式的使用VLOOKUP,如何用在两张表中使用VLOOKUP函数

另外一位老师用了这个代码:

On Error Resume Next

Dim i, j As Integer

Set myDocument1 = ThisWorkbook.Worksheets("开票明细").Range("b6:c1000")

Set myDocument2 = ThisWorkbook.Worksheets("ERP匹配")

Set myDocument3 = ThisWorkbook.Worksheets("收入明细账").Range("F5:H1000")

Set myDocument4 = ThisWorkbook.Worksheets("收入明细账").Range("F5:F1000")

Set myDocument5 = ThisWorkbook.Worksheets("收入明细账").Range("E5:F1000")

For i = 1 To myDocument2.Range("a65536").End(xlUp).Row

If myDocument2.Cells(i, 2) <> "" Then

myDocument2.Cells(i, 7) = Application.WorksheetFunction.VLookup(myDocument2.Cells(i, 2), myDocument1, 2, [0])

Else

myDocument2.Cells(i, 7) = ""

End If

If myDocument2.Cells(i, 3) <> "" Then

myDocument2.Cells(i, 6) = Application.WorksheetFunction.VLookup(myDocument2.Cells(i, 3), myDocument3, 2, [0])

myDocument2.Cells(i, 4) = Application.WorksheetFunction.VLookup(myDocument2.Cells(i, 3), myDocument3, 3, [0])

myDocument2.Cells(i, 5) = Application.WorksheetFunction.Index(myDocument5, Application.WorksheetFunction.Match(myDocument2.Cells(i, 3), myDocument4, 0), 1)

Else

myDocument2.Cells(i, 6) = ""

myDocument2.Cells(i, 4) = ""

myDocument2.Cells(i, 5) = ""

End If

Next

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值