[VBA]删除表中所有含

1537阅读 0评论2007-01-17 Intranet
分类:项目管理

''delete cell

Sub delete()
    ''ActiveWorkbook.Sheets(1).Rows("3").delete
    On Error GoTo DelError
       Do
          Cells.Find(What:=0, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
                  xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
                  , SearchFormat:=False).Activate
          Selection.ClearContents
       Loop
    DelError:
          MsgBox "Delete complete!"
  


End Sub
------------------
''delete row

      On Error GoTo DelError
         Do
          Cells.Find(what:="0", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
                  xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
                  , SearchFormat:=False).Activate
          ''Selection.ClearContents
          Rows(Selection.Row).Select
          Selection.delete Shift:=xlUp
         Loop
      DelError:
          MsgBox "Delete complete!"


--------------
''delete if H* = 0

    Dim I%, Arr(1 To 256), K%, J%, L%
        For I = 1 To 256
            Arr(I) = Cells(65536, I).End(xlUp).Row
        Next
          K = Application.WorksheetFunction.Max(Arr)
           For J = K To 1 Step -1
               For L = 1 To 256
                   If InStr(Cells(J, L), "0") > 0 Then
                   Rows(J).Delete
                   Exit For
                   End If
               Next
       
           Next

上一篇:how to download internet explorer 6 sp1 (full setu
下一篇:Excel单元格内按时间规律显示名言警句