Some of the font colour in the cell is blue, after the execution of the macro, it…
- User
Some of the font colour in the cell is blue, after the execution of the macro, it becomes black, any solution on that?
Assistant
You're right - the macro is losing the original formatting when it replaces the cell value. Here's an updated version that preserves the original font colors and other formatting:
Sub DeleteStrikethroughText() Dim ws As Worksheet Dim cell As Range Dim i As Integer Dim charPos As Integer Dim cellLength As Integer Set ws = ActiveSheet ' Loop through all used cells in the worksheet For Each cell In ws.UsedRange If cell.Value <> "" Then cellLength = Len(cell.Value) charPos = 1 ' Loop through characters from end to beginning to avoid position shifting For i = cellLength To 1 Step -1 ' If the character has strikethrough formatting, delete it If cell.Characters(i, 1).Font.Strikethrough Then cell.Characters(i, 1).Delete End If Next i End If Next cell MsgBox "Strikethrough text has been removed from all cells while preserving formatting." End Sub
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.