简体   繁体   English

清除列中任何在文本字符串中包含双引号的单元格的内容

[英]Clear contents of any cell in column that contain a double quote in the text string

I need to clear the contents of any cell in column K that contains a double quote ( " ) in the text string. The text strings will differ some will say 3" hose , some will say 10" road so it won't be the same and it is only within that column that I need the contents of the cell cleared (not deleted, I don't want the remaining data to move). 我需要清除K列中任何在文本字符串中包含双引号( " )的单元格的内容。文本字符串会有所不同,有些会说3" hose ,有些会说10" road所以它不会是相同,只是在该列中,我需要清除单元格的内容(不删除,我不希望其余数据移动)。

Here is what I have tried: 这是我尝试过的:

Sub Macro4()
    Rows("3:3").Select
    Selection.AutoFilter
    Range("K2").Select
    ActiveSheet.Range("$A$3:$V$3225").AutoFilter Field:=11, Criteria1:="=*""*" _
      , Operator:=xlAnd
    Range("K45").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    Rows("3:3").Select
    Range("E3").Activate
    Selection.AutoFilter
    Range("A4").Select
End Sub

Answer posted in comments: 答案发表在评论中:

Columns("K:K").Select
Selection.Replace What:="''", Replacement:="", LookAt:=xlPart, _
  SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
  ReplaceFormat:=False

Although you should never use .Select so I would use: 虽然您永远不要使用.Select所以我会使用:

Columns("K:K").Replace What:="''", Replacement:="", LookAt:=xlPart, _
  SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
  ReplaceFormat:=False

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM