Hello,
I have implemented a simple VBA code that deletes the word "hello" from all the cells in column E.
The issue is that when I run the code, it also removes the formatting of words that are bold or italic. It appears that running VBA code to delete or replace content inside cells also removes the formatting.
Is there a solution to preserve formatting?
Thank you.
I have implemented a simple VBA code that deletes the word "hello" from all the cells in column E.
Code:
Sub DeleteHelloInColumnE()
Dim ws As Worksheet
Dim cell As Range
Set ws = ActiveSheet
For Each cell In ws.Range("E1:E" & ws.Cells(ws.Rows.Count, "E").End(xlUp).Row)
cell.Value = Replace(cell.Value, "hello", "")
Next cell
End Sub
The issue is that when I run the code, it also removes the formatting of words that are bold or italic. It appears that running VBA code to delete or replace content inside cells also removes the formatting.
Is there a solution to preserve formatting?
Thank you.