Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. Dim matchRange As Range, firstMatchRange As Range
  2. Set matchRange = ws.columns(COLUMN_TO_SEARCH_IN).Find( _
  3. What:=VALUE_TO_SEARCH_BY, LookIn:=xlValues, LookAt:=xlWhole, _
  4. SearchOrder:=xlByRows, MatchByte:=False)
  5. ' Don't forget that the match will be the cell only, you will need
  6. ' to get the entire row from that for usual processing.
  7.  
  8. ' Check if there's a match at all
  9. If Not matchRange Is Nothing Then
  10. ' Memorize first match to be able to recognize whether we've got
  11. ' back to start
  12. Set firstMatchRange = matchRange
  13. Do
  14. ' ... DO PROCESSING ON THE MATCH...
  15.  
  16. ' ...and jump to the next one
  17. Set matchRange = _
  18. ws.columns(COLUMN_TO_SEARCH_IN).FindNext(matchRange)
  19. Loop While Not matchRange Is Nothing And _
  20. matchRange.Address <> firstMatchRange.Address
  21. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement