Search columns if value match's in three columns then pulls information

jmcgillis14

New Member
Joined
Sep 24, 2014
Messages
12
I want to pull the GL Code from List to and into the cells in column D. I would like to search List 2 and if date matches, vendor matches, and amount matches, then it pulls the GL Code from column H and populates column D.
List 1List 2
DateVendorAmountGL Code (need this)DateVendorGL CodeAmount
5/1/2022Wal Mart51/1/2021Cafe Fresh444499
6/3/2019Sams Club991/5/2022Amazon777715
1/5/2022Amazon156/3/2019Sams Club888899
8/5/2021Home Depot68/5/2021Home Depot151560
3/1/2019Lowes202065
5/1/2022Wal Mart55555

Much appreciate the help!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
VBA Code:
Public Sub GlCode()
Dim i As Integer
Dim j As Integer

For i = 3 To WorksheetFunction.CountA(Range("a1:a3000"))
   
    For j = 3 To WorksheetFunction.CountA(Range("f1:f3000"))
       
        'if statement For Date
        If Cells(i, 1).Value = Cells(j, 6).Value Then
           
            'if statement For Vendor
            If Cells(i, 2).Value = Cells(j, 7).Value Then
           
                'if statement For Amount
                If Cells(i, 3).Value = Cells(j, 9).Value Then
               
                    Cells(i, 4).Value = Cells(j, 8).Value
               
                'end if For Amount
                End If
               
            'end if For Vendor
            End If
           
        'end if For Date
        End If
       
    Next j
Next i

End Sub

Hope this works!
 
Upvote 0

Forum statistics

Threads
1,215,145
Messages
6,123,291
Members
449,094
Latest member
GoToLeep

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