相关疑难解决方法(0)

如果单元格包含字符串X,则删除整行

我是VBA的新手,我正试图想出一种方法来删除网站列单元格包含单词的所有行(如果可能的话,移动单元格)none.该表包含5000多条记录,这将为我节省大量时间.

我很感激任何建议.提前谢谢了!

http://i39.tinypic.com/5ano1d.png

excel vba excel-2007 excel-vba excel-2010

35
推荐指数
4
解决办法
28万
查看次数

基于搜索关键字VBA删除行

我试图删除使用VBA在B列中找到值"X"的每一行.但是,我有三个问题:

  1. 我无法使用cells.find方法将我的VBA代码从活动单元格下移到下一个单元格(B3)(请参阅下面的代码)
  2. 我的代码不会删除在B列中找到值"X"的整行
  3. B列中的数据量可能会有所不同:它可以在今天的B10结束,或明天的B100结束(参见下面的屏幕截图)

任何帮助将不胜感激.

Sub RemoveRows()   
    Dim strLookFor As String
    Dim strRow As String

    Worksheets("Sheet1").Range("B2").Activate

    strLookFor = "X"
    strRow = Range("B2").Address

    Do Until ActiveCell.Value = ""        
        MsgBox (ActiveCell.Value)        
        If ActiveCell.Value = strLookFor Then
            Rows.Delete (strRow)
        End If            
        strRow = Cells.Find(what:=strLookFor).Address
    Loop

    MsgBox ("Deleted all rows with value " & strLookFor)    
End Sub
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

excel vba excel-vba

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

excel ×2

excel-vba ×2

vba ×2

excel-2007 ×1

excel-2010 ×1