Advertisement
YasserKhalil2019

T4172_Highlight Rows Do Not Exist In Another Sheet

Oct 18th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. https://excel-egy.com/forum/t4172
  2. ---------------------------------
  3.  
  4. Sub Highlight_Rows_Do_Not_Exist_In_Another_Sheet()
  5. Dim ws As Worksheet, sh As Worksheet, rng As Range, c As Range, m As Long, n As Long, i As Long
  6.  
  7. Application.ScreenUpdating = False
  8. Set ws = ThisWorkbook.Worksheets(1)
  9. Set sh = ThisWorkbook.Worksheets(2)
  10.  
  11. m = ws.Cells(Rows.Count, 1).End(xlUp).Row
  12. n = sh.Cells(Rows.Count, 1).End(xlUp).Row
  13.  
  14. For Each c In ws.Range("A2:D" & m).Rows
  15. c.Offset(, c.Columns.Count + 2).Cells(1).Value = Application.Trim(Join(Application.Index(c.Value, 1, 0)))
  16. Next c
  17.  
  18. For Each c In sh.Range("A2:D" & n).Rows
  19. c.Offset(, c.Columns.Count + 2).Cells(1).Value = Application.Trim(Join(Application.Index(c.Value, 1, 0)))
  20. Next c
  21.  
  22. For i = 1 To n
  23. Set rng = ws.Range("G:G").Find(sh.Cells(i, 7))
  24. If rng Is Nothing Then sh.Cells(i, 1).Resize(1, 4).Interior.Color = vbRed
  25. Next i
  26.  
  27. ws.Columns(7).Clear: sh.Columns(7).Clear
  28. Application.ScreenUpdating = True
  29. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement