简体   繁体   English

根据查找值将值从一张表匹配并粘贴到另一张表中

[英]Match and paste value from one sheet into another based on a Lookup value

i have two sheets, Bills and Reconciliation, Both have Bill ID in column B. what i need is a vba code which will copy values from Column P,Q and W of Reconciliation sheet and paste these values in Column P,Q And W of Sheet Bills against same Bill ID.我有两张纸,账单和对账,B 列都有账单 ID。我需要一个 vba 代码,它将复制对账表的 P、Q 和 W 列的值,并将这些值粘贴到 P、Q 和 W 列针对同一账单 ID 的表单账单。 In Sheet Reconciliation Bill Id starts from Row21 and can be dynamic, so last row function will be used.在 Sheet Reconciliation Bill Id 从 Row21 开始并且可以是动态的,所以最后一行 function 将被使用。 in sheet Bills Bill id starts from B2 and can go till B100000 Or more在表 Bills Bill id 从 B2 开始,可以 go 到 B100000 或更多

Dim wb As Workbook: Set wb = ThisWorkbook
Dim wsDisp As Worksheet: Set wsDisp = wb.Worksheets("Reconciliation")


Dim a As String
Dim b As String
Dim c As String
Dim e As Long
Dim F As String




 Application.ScreenUpdating = False

 a = wsDisp.Cells(19, 16).Value
 b = wsDisp.Cells(19, 17).Value
 c = wsDisp.Cells(19, 23).Value


e = MsgBox("Do You Wish to Save Recovery ? " & vbNewLine & "GIDC PAID = " & a & vbNewLine & "GST PAID = " & b & vbNewLine & " LPS PAID = " & c, vbYesNo)


If e = vbNo Then Exit Sub



   For i = 21 To 400
   
    
       Sheets("Bills").Cells(Cells(i, 2), 16) = Sheets("Reconciliation").Cells(i, 16)
       Sheets("Bills").Cells(Cells(i, 2), 17) = Sheets("Reconciliation").Cells(i, 17)
       Sheets("Bills").Cells(Cells(i, 2), 23) = Sheets("Reconciliation").Cells(i, 23)

    

  Next

Application.ScreenUpdating = True

Reconciliation sheet对账表

在此处输入图像描述

Bills sheet帐单

在此处输入图像描述

I have similar situation and have this solution that works for me, i use VLookup in this case if Bill NR are ascending.我有类似的情况,并且有适合我的解决方案,如果 Bill NR 上升,我在这种情况下使用 VLookup。

You can make record macro to get VLookup and use this copy function to get values in your sheet.您可以制作记录宏来获取 VLookup 并使用此副本 function 来获取工作表中的值。

Range("P21").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-10],Reconciliation shee!R2B1:R10000P5,5,FALSE)"
    Range("P21").Select
    Selection.AutoFill Destination:=Range("P21:P" & LastRow), Type:=xlFillDefault
    Range("P21:P" & LastRow).Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从另一张纸上的单元格值复制同一张纸中范围的一部分的粘贴范围 - Copy Range From One Sheet Paste Part of Range In Same Sheet Based On Cell Value On Another Sheet 根据单元格值将数据从一张表复制并粘贴到另一张表 - Copy and paste data from one sheet to another sheet(s) based on cell value 将每个唯一值从一张纸复制并粘贴到另一张纸 - Copy & paste each unique value from one sheet to another 根据名称在另一个工作表中查找值 - Lookup value in another sheet based on name 我正在尝试从一张纸查找值到另一张纸 - I am try to lookup value from one sheet to another sheets 如果一张纸中的值与另一张纸匹配,则将该行粘贴到另一张纸中 - If value from one sheet matches in another sheet then paste that row in another sheet 循环浏览一张工作表中的列值,并将另一列中的COUNTIF值粘贴到另一张工作表中 - Loop through column values from one sheet and paste COUNTIF value from another column into another sheet 根据另一张纸上的订单号从一张纸上查找列值 - Find column value from one sheet based on the order # on another sheet 基于一个单元格值复制行并引用另一个单元格值并粘贴到新工作表上 - Copy rows based on one cell value and in reference to another cell value and paste on a new sheet 基于自动过滤器将粘贴列从一张工作表复制到另一张工作表 - Copy Paste Columns from one sheet to another sheet based on Autofilter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM