How to Highlight Specific Text within a Cell In Excel

Поділитися
Вставка
  • Опубліковано 4 гру 2024

КОМЕНТАРІ • 18

  • @lynnekilgore6011
    @lynnekilgore6011 2 місяці тому

    You have no idea how much time this just saved me. Thank you!

    • @Excel10tutorial
      @Excel10tutorial  2 місяці тому

      Glad to hear that. Please subscribe and share

  • @johngcullen6829
    @johngcullen6829 6 місяців тому +2

    Excellent - thanks so much. Been looking for something that worked for hours.

    • @Excel10tutorial
      @Excel10tutorial  6 місяців тому

      Glad you like it. Please subscribe and be with us

  • @omerfarukengin6988
    @omerfarukengin6988 8 місяців тому

    Works perfectly, thanks a lot!

    • @Excel10tutorial
      @Excel10tutorial  8 місяців тому

      You're most welcome. Please subscribe and be with us.

  • @phuongpt1204
    @phuongpt1204 Місяць тому

    Thank you so much! Can you give me the code for highlight all of the words from a wordlist within cells. I mean, i want to colour many different words at the same time

  • @swendingo
    @swendingo 4 місяці тому +1

    Can we make it so it isn't case sensitive?

    • @Malmosfotograf
      @Malmosfotograf 3 місяці тому

      Sub HighlightLängdInColumnQ()
      ' This macro highlights occurrences of the word "längd" (case-insensitive) in each cell in column Q.
      ' Disable screen updating to improve performance
      Application.ScreenUpdating = False
      ' Declare variables
      Dim targetCell As Range ' The cell in column Q where "längd" will be searched and highlighted
      Dim searchText As String ' The text string to be highlighted
      Dim tempString As String ' Temporary string to keep track of the processed text
      Dim startIdx As Long ' Starting index for highlighting
      Dim occurrenceCount As Long ' Number of occurrences found in each cell
      ' Set the text string to "längd"
      searchText = "längd"
      ' Calculate the length of the search text
      Dim searchTextLength As Long
      searchTextLength = Len(searchText)
      ' Loop through each cell in column Q within the selected range
      For Each targetCell In Range("Q:Q").Cells
      If Not IsEmpty(targetCell) Then
      With targetCell
      ' Convert cell content and search text to lowercase for case-insensitive comparison
      Dim cellContent As String
      cellContent = LCase(targetCell.Value)
      Dim searchLower As String
      searchLower = LCase(searchText)
      ' Find the number of occurrences of "längd" (case-insensitive) in the cell
      occurrenceCount = UBound(Split(cellContent, searchLower))
      ' Check if there is at least one occurrence
      If occurrenceCount > 0 Then
      ' Initialize the temporary string
      tempString = ""
      ' Loop through each occurrence
      For startIdx = 0 To occurrenceCount - 1
      ' Concatenate the text before the occurrence to the temporary string
      tempString = tempString & Split(cellContent, searchLower)(startIdx)
      ' Highlight the current occurrence of "längd" (preserving original case)
      .Characters(Start:=Len(tempString) + 1, Length:=searchTextLength).Font.ColorIndex = 3 ' Red color
      ' Concatenate the search text to the temporary string
      tempString = tempString & Mid(targetCell.Value, Len(tempString) + 1, searchTextLength)
      Next startIdx
      End If
      End With
      End If
      Next targetCell
      ' Re-enable screen updating
      Application.ScreenUpdating = True
      End Sub

  • @LinuxSaravanan
    @LinuxSaravanan 9 місяців тому

    Thank you brother, very good I tried it's working well❤❤❤❤

    • @Excel10tutorial
      @Excel10tutorial  9 місяців тому

      Glad you like it. Please subscribe and share

  • @kromox8178
    @kromox8178 6 місяців тому

    Thanks bro.

  • @Meepbeeped
    @Meepbeeped 2 місяці тому

    Do you have a video like this that would hide or delete text from a sentence? So instead of highlighting excel, it would delete the word?

    • @Excel10tutorial
      @Excel10tutorial  2 місяці тому

      Change the following line from the code:
      .Characters(Start:=Len(tempString) + 1, Length:=searchTextLength).Font.ColorIndex = 5
      To This:
      .Characters(Start:=Len(tempString) + 1, Length:=searchTextLength).Delete

  • @danielrawinis2671
    @danielrawinis2671 3 місяці тому

    Hi its great tool, thanks for that, but doesnt work when I try to highlight results of the formula, its highlighting whole cell. Any solution for that ?
    example:
    if I type "Hi my name is Dan" in A1 and trying to highlight "Dan" - it works
    but If i textjoin B1+C1 and a result in A1 is "Hi my name is Dan" then it doesnt work as is highlighting whole sentence

  • @studywithamisha9903
    @studywithamisha9903 7 місяців тому

    Where is code plx give link