Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Set ws = Me
Dim p As Long
Dim r As Long
Dim lastRow As Long
Dim raw As String
Dim completed As Object
Set completed = CreateObject("Scripting.Dictionary")
'--- 1) O열의 완료된 단어 수집 ---
lastRow = ws.Cells(ws.Rows.Count, "O").End(xlUp).Row
For p = 1 To lastRow
raw = Trim(ws.Cells(p, "O").Value)
If Len(raw) > 0 Then
raw = Replace(raw, " ", "")
raw = Replace(raw, vbCrLf, "")
raw = Replace(raw, vbTab, "")
If Not completed.Exists(UCase(raw)) Then
completed.Add UCase(raw), True
End If
End If
Next p
'--- 2) E열의 각 셀에서 단어 매칭 후 부분 취소선 적용 ---
Dim txt As String
Dim startPos As Long
Dim key As Variant
Dim tmpTxt As String
Dim foundPos As Long
lastRow = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row
For r = 1 To lastRow
txt = ws.Cells(r, "E").Value
' 기존 취소선 초기화
ws.Cells(r, "E").Font.Strikethrough = False
'--- (추가 기능) K열이 "O" 또는 "o"일 경우 전체 취소선 ---
If UCase(Trim(ws.Cells(r, "K").Value)) = "O" Then
ws.Cells(r, "E").Font.Strikethrough = True
Else
' 각 O열 단어별로 부분 취소선 적용
For Each key In completed.Keys
tmpTxt = UCase(txt)
foundPos = InStr(1, tmpTxt, UCase(key))
Do While foundPos > 0
ws.Cells(r, "E").Characters(foundPos, Len(key)).Font.Strikethrough = True
foundPos = InStr(foundPos + Len(key), tmpTxt, UCase(key))
Loop
Next key
End If
Next r
End Sub