Advertisement
Guest User

test

a guest
Jul 3rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub LoopRange()
  2.  
  3.     Dim rCell As Range
  4.     Dim aRangeRng As Range
  5.     Dim bRangeRng As Range
  6.     Dim Rng As Range
  7.     Dim FindString As String
  8.  
  9.  
  10.     Set aRangeRng = ActiveWorkbook.ActiveSheet.Range("A2:A2438")
  11.     Set bRangeRng = ActiveWorkbook.ActiveSheet.Range("B2:S2438")
  12.     For Each aCell In bRangeRng
  13.         FindString = aCell.Value
  14.         With aRangeRng
  15.         Set Rng = .Find(What:=FindString, _
  16.                         After:=.Cells(.Cells.Count), _
  17.                         LookIn:=xlValues, _
  18.                         LookAt:=xlWhole, _
  19.                         SearchOrder:=xlByRows, _
  20.                         SearchDirection:=xlNext, _
  21.                         MatchCase:=False)
  22.         If Not Rng Is Nothing Then
  23.             aCell.Interior.ColorIndex = 37
  24.         Else
  25.             aCell.Interior.ColorIndex = 38
  26.         End If
  27.         End With
  28.  
  29.     Next aCell
  30. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement