使用vba删除范围内的删除线单元格

我有500行和大约13列的数据在一个表中。

即使单元格包含所有字符作为穿透,我也需要删除单元格内容本身,但如果单元格包含某些文本和穿透的组合,则应该单独删除穿透单元,并将其余文本留在单元格中。

这是我的excel的样子

ABCDEFGHIJKLM 1.2 SERVER_P RE1 **GR5** 7.3 PROXY NET 4.5 NET **CON** V1 GR 

如果**里面的文字是透视的话,我预计在第一行L列应该是空的,第三行应该删除CON,所以它应该保持“NET V1”。

这是我到现在为止

 Dim Cell As Range Dim iCh As Integer Dim NewText As String Sheets("Copy_indications").Select With ActiveSheet 'count the rows till which strings are there Lrow = .Cells(.Rows.Count, "B").End(xlUp).Row End With For Each Cell In Range("B1:M" & Lrow) For iCh = 1 To Len(Cell) With Cell.Characters(iCh, 1) If .Font.Strikethrough = False Then NewText = NewText & .Text End If End With Next iCh NewText = Cell.Value Cell.Characters.Font.Strikethrough = False Next Cell 

如果单元格包含某些文本和穿透的组合,我的macros将删除所有穿透字符,但是如果单元格包含所有字符作为穿透,则不删除它们,而是删除它们。

有人可以帮助我这个。

良好的解决scheme,只是纠正了一些错误(见代码中的注释)

 Dim Cell As Range, iCh As Integer, NewText As String With Sheets("Copy_indications") ' <~~ avoid select as much as possible, work directly with the objects Lrow = .Cells(.Rows.Count, "B").End(xlUp).Row For Each Cell In .Range("B1:M" & Lrow) For iCh = 1 To Len(Cell) With Cell.Characters(iCh, 1) If .Font.Strikethrough = False Then NewText = NewText & .Text End With Next iCh Cell.Value = NewText ' <~~ You were doing it the other way around NewText = "" ' <~~ reset it for the next iteration Cell.Characters.Font.Strikethrough = False Next Cell End With