Excel 从一个工作表到另一个工作表进行编辑

Excel 从一个工作表到另一个工作表进行编辑,excel,vba,vlookup,Excel,Vba,Vlookup,我正在寻找vlookup并使用VBA从采购记录更新库存表/表中的成本/余额 Worksheets("Purchase Record")(VLOOKUP(H16,Inventory[#Data],10,0)= _ Worksheets("Purchase Record").Range("O16") 'lookup and add stock Worksheets("Purchase Record")(VLOOKUP(H16,Inventory[#Data],7,0)= _ Work

我正在寻找vlookup并使用VBA从采购记录更新库存表/表中的成本/余额

Worksheets("Purchase Record")(VLOOKUP(H16,Inventory[#Data],10,0)= _
   Worksheets("Purchase Record").Range("O16") 'lookup and add stock 

Worksheets("Purchase Record")(VLOOKUP(H16,Inventory[#Data],7,0)= _
   Worksheets("Purchase Record").Range("C16"+ (VLOOKUP(H16Inventory[#Data],7,0).VALUE

这看起来像是您要做的:

Sub Tester()

    Dim tbl As ListObject, sht As Worksheet, m, id, rw As Range

    Set sht = Worksheets("Purchase Record")
    Set tbl = sht.ListObjects("Inventory")

    id = sht.Range("H16").Value 'value to match against the table

    m = Application.Match(id, tbl.ListColumns("Data").DataBodyRange, 0) 'try to match the ID

    If Not IsError(m) Then

        Set rw = tbl.DataBodyRange.Rows(m) '<< this is the matching row in your table/listobject

        'best guess at what you're wanting to do...
        rw.Cells(10).Value = sht.Range("O16").Value
        rw.Cells(7).Value = rw.Cells(7).Value + sht.Range("C16").Value

    End If

End Sub
子测试仪()
Dim tbl作为列表对象,sht作为工作表,m、id、rw作为范围
Set sht=工作表(“采购记录”)
设置tbl=sht.ListObjects(“库存”)
id=要与表匹配的sht.范围(“H16”).值
m=Application.Match(id,tbl.ListColumns(“数据”).DataBodyRange,0)”尝试匹配该id
如果不是IsError(m),则

设置rw=tbl.DataBodyRange.Rows(m)'不能只将工作表状态下的VLOOKUP公式添加到VBA。你能解释一下你到底想做什么吗?@Pancho-也许可以添加一个设置的屏幕截图?这将有助于形象化你想做什么。我们可以从您的代码中猜出,但是更多的细节会有所帮助。