vlookup from one excel file to another based on a specific value

froggy76

New Member
Joined
Sep 13, 2014
Messages
2
Hi Everybody . I am trying to do the following : If column X in excel 1 is not 00.00.00 , then vlookup data from sheet 1 with data in sheet based on following criteria :
if value in column 1,3,7,14,28,51 in sheet 1 = value in column 1,3,7,14,28,51 , ignore the lines
but if one of the criteria differ from the second sheet , the line should be kept . The code : Sub Check()
Dim Sheet1 As Worksheet

Dim Sheet2 As Worksheet
Set Sheet2 = Worksheets("xxx")
Dim Sheet3 As Worksheet
Set Sheet3 = Worksheets("xxxx")
Workbooks.Open Filename:="xxx"
Set Sheet1 = Workbooks("x").Worksheets(xx"Sheet1")
Sheet3.Activate
Dim off
off = 2
Dim off2
off2 = 3
Dim off3
off3 = 0
Dim Found
Found = 0
Sheet3.Range("Ax:AYxxx").Clear
Do Until Sheet1.Cells(off, 1) = ""
If (Sheet1.Cells(off, 28) <> "00:00:00") Then
Do Until (Sheet2.Cells(off2, 1) = "" Or Found = 1)
If (Sheet1.Cells(off, 1).Value = Sheet2.Cells(off2, 1).Value And Sheet1.Cells(off, 3).Value = Sheet2.Cells(off2, 3).Value And Sheet1.Cells(off, 7).Value = Sheet2.Cells(off2, 7).Value And Sheet1.Cells(off, 14).Value = Sheet2.Cells(off2, 14).Value And Sheet1.Cells(off, 43).Value = Sheet2.Cells(off2, 43).Value And Sheet1.Cells(off, 51).Value = Sheet2.Cells(off2, 51).Value And Sheet1.Cells(off, 28).Value=Sheet2.Cells(off2, 28).Value ) Then
Found = 1
End If
off2 = off2 + 1
Loop
If (Found = 0) Then
off3 = off3 + 1
For j = 1 To 51
Sheet3.Cells(off3, j) = Sheet1.Cells(off, j).Value
Next j
End If
End If
off = off + 1
off2 = 3
Found = 0
Loop
Workbooks("xxx").Close SaveChanges:=False
End Sub

Thank you for your help
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

froggy76

New Member
Joined
Sep 13, 2014
Messages
2
Hi Everybody , Any idea ? I am really stuck and I can not finalize the project , due on Monday .
Thks.
 
Upvote 0

Forum statistics

Threads
1,191,121
Messages
5,984,764
Members
439,909
Latest member
daigoku

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
Top