簡體   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