Advertisement
sathana

HighlightHysterectomy

Oct 27th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Sub HighlightHysterectomy()
  2. Dim cell As Range
  3. Dim ws As Worksheet
  4. Dim searchText As String
  5.  
  6. searchText = "hysterectomy"
  7.  
  8. ' Loop through all worksheets in the workbook
  9. For Each ws In ThisWorkbook.Worksheets
  10. ' Loop through all cells in the worksheet
  11. For Each cell In ws.UsedRange
  12. ' Check if the cell contains the word "hysterectomy"
  13. If InStr(1, cell.Text, searchText, vbTextCompare) > 0 Then
  14. ' Highlight the cell
  15. cell.Interior.Color = RGB(255, 0, 0) ' Highlight color: Red
  16. End If
  17. Next cell
  18. Next ws
  19. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement