繁体   English   中英

如何编写VBA脚本来删除包含特定字符串的范围内的所有单元格?

[英]How can you write a VBA script to delete all cells in a range containing a certain string?

如果我有大量的单元格,并且我想删除所有只包含“,”或类似的单元格,我怎么能在代码中表达这个? 我正在思考一些事情

If Range("C1:C100").Value = "," Then 
Active.Cell.Delete Shift:=xlRight 

我知道这很糟糕,但希望它能让我明白这一点。

谢谢!

从概念上讲(现在不在Excel前面)

dim cel as range
for each cel in Range("C1:C100")
   if cel.Value = "," Then
      cel.Delete Shift:=xlRight 
   end if
next cel

暂无
暂无

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

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