Macro for this post solution, ( written by the son of God )
http://www.excelfox.com/forum/showth...ll=1#post12897
Code:Sub conditionally_delete3() ' http://www.excelfox.com/forum/showthread.php/2436-conditionally-delete-entire-row?p=12893&viewfull=1#post12893 Rem 1 Worksheets info Dim Wb1 As Workbook, Wb2 As Workbook, Ws1 As Worksheet, Ws2 As Worksheet Set Wb1 = Workbooks("STEP1U.xlsb") ' Workbooks("sample1.xlsx") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Upstox\STEP1U.xlsb") Set Ws1 = Wb1.Worksheets.Item(1) ' worksheet of first tab Set Wb2 = Workbooks("1.xls") ' Workbooks("sample2.xlsx") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls") Set Ws2 = Wb2.Worksheets.Item(1) ' worksheet of first tab '1b Ranges Dim Rng1A As Range, Rng2B As Range Set Rng1A = Ws1.Range("A2:A" & Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row & "") Set Rng2B = Ws2.Range("B2:B" & Ws2.Range("B" & Ws2.Rows.Count & "").End(xlUp).Row & "") Rem 2 Delete an entire row in Ws2 if value in column B is not anywhere in column A of Ws1 Dim Rws As Long For Rws = Ws2.Range("B" & Ws2.Rows.Count & "").End(xlUp).Row To 2 Step -1 Dim rngFnd As Range Set rngFnd = Rng1A.Find(what:=Ws2.Range("B" & Rws & "").Value, After:=Rng1A.Item(1), LookIn:=xlValues, LookAt:=xlPart, searchorder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) ' https://stackoverflow.com/questions/49094391/excel-vba-range-findnext-v-range-find-what-have-i-missed/49181464#49181464 If rngFnd Is Nothing Then ' The value from column B in Ws2 was not found in column A of Ws1 Ws2.Range("B" & Rws & "").EntireRow.Delete Shift:=xlUp Else ' The value from column B in Ws2 was found in column A of Ws1 so do nothing End If Next Rws ' Wb1.Save ' Wb1.Close ' Wb2.Save ' Wb2.Close End Sub
1.xls: https://app.box.com/s/th2xzmkh7rnfr4qf4dho1kpgudndm073




Reply With Quote
Bookmarks