Advertisement
sathana

highlight hysterectomy column

Oct 27th, 2023
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. Sub HighlightHysterectomyInColumn()
  2. Dim ws As Worksheet
  3. Dim rng As Range
  4. Dim cell As Range
  5. Dim targetColumn As Range
  6. Dim searchText As String
  7.  
  8. ' Specify the column where you want to search for "hysterectomy"
  9. Set ws = ThisWorkbook.Worksheets("Sheet1") ' Change "Sheet1" to your sheet name
  10. Set targetColumn = ws.Range("A:A") ' Change "A:A" to your target column
  11.  
  12. searchText = "hysterectomy"
  13.  
  14. ' Loop through each cell in the specified column
  15. For Each cell In targetColumn
  16. ' Check if the cell contains the word "hysterectomy"
  17. If InStr(1, cell.Value, searchText, vbTextCompare) > 0 Then
  18. ' Highlight the cell
  19. cell.Interior.Color = RGB(255, 0, 0) ' Highlight color: Red
  20. End If
  21. Next cell
  22. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement