+ Reply to Thread
Results 1 to 2 of 2

Delete Cells With a Certain Value

Hybrid View

  1. #1
    Registered User
    Join Date
    03-22-2010
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Delete Cells With a Certain Value

    I have a column with some cells which have a value of zero. I want to delete, not clear those cells that have a value of zero. Do I need to use a loop? I am very new to this, so this is all I have. Thanks for any help
    DeleleCells()
    Columns("G:H").Select
    
    If ActiveCell.Value = "0" Then
    ActiveCell.Delete Shift:=xlUp
    End If
    
    End Su
    b
    Last edited by Leith Ross; 03-23-2010 at 08:40 PM. Reason: Added Code Tags

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Delete Cells With a Certain Value

    Option Explicit
    
    Sub Delete_Zero_Cells()
    
        Application.ScreenUpdating = False
        
        With ActiveSheet
            If .AutoFilterMode = True Then .AutoFilterMode = False
            
            Range("G1").CurrentRegion.Resize(, 1).AutoFilter field:=1, Criteria1:="=0", Operator:=xlAnd, Criteria2:="=0"
            Range("G1").CurrentRegion.SpecialCells(xlCellTypeVisible).Delete shift:=xlUp
                
        
            Range("G1").CurrentRegion.Resize(, 1).Offset(, 1).AutoFilter field:=1, Criteria1:="=0", Operator:=xlAnd, Criteria2:="=0"
            Range("G1").CurrentRegion.Resize(, 1).Offset(, 1).SpecialCells(xlCellTypeVisible).Delete shift:=xlUp
            
            .AutoFilterMode = False
            
        End With
        
        Application.ScreenUpdating = True
    
    End Sub
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1