[英]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.