matching and copying data from one sheet to another

danwilkin

New Member
Joined
Sep 18, 2011
Messages
8
I have 2 sheets. one is the price list sheet including a column (col D) containing numbers (these are not calculated). i want to extract these numbers into the other sheet which is a sheet of invoices. i need to copy the data (col D).
In each row there are 3 conditions to match. col a and col b and col c must match in both sheets in order to satisfy copying the info from col D.
Is there an easy way to do this?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
With VBA try: (not tested)
Code:
Sub Update_Invoices()
    Dim dataInv As Range
    Dim dataPri As Range
    Dim i As Integer
    Dim p As Integer
    
    Set dataInv = Sheets("Invoice").Cells(1, 1).CurrentRegion
    Set dataPri = Sheets("Price").Cells(1, 1).CurrentRegion
    
    For i = 1 To dataInv.Rows.Count
        For p = 1 To dataPri.Rows.Count
            If dataInv.Cells(i, 1) = dataPri.Cells(p, 1) And _
                dataInv.Cells(i, 2) = dataPri.Cells(p, 2) And _
                dataInv.Cells(i, 3) = dataPri.Cells(p, 3) Then
                
                dataInv.Cells(i, 4) = dataPri.Cells(p, 4)
                Exit For
            End If
        Next p
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top