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. In Sheet Reconciliation Bill Id starts from Row21 and can be dynamic, so last row function will be used. in sheet Bills Bill id starts from B2 and can go till B100000 Or more
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.
You can make record macro to get VLookup and use this copy function to get values in your sheet.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.