+ Reply to Thread
Results 1 to 3 of 3

Excel Macro deleting rows contain "0"

  1. #1
    Registered User
    Join Date
    06-25-2008
    Posts
    7

    Excel Macro deleting rows contain "0"

    hi all, im new to this forum and i have a question regarding a macro i wrote.

    my file contains 4 columns and over 50k row, the macro will sort the data according to column D in descending order, and only around 700 of them (data in column d) will contain data that's not a zero.

    what i want to do is to delete all the rows whose column D has a value of 0.

    here is the code i wrote but it's not working

    PHP Code: 
    Sub deleteit()
            
    Set myRange Range("D2"Range("D65536").End(xlUp))
            
    myRange.Cells(0).EntireRow.Delete
    End Sub 
    can someone please help me?
    Last edited by skyt; 06-25-2008 at 02:00 PM.

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-25-2008
    Posts
    7
    hi and thanks for the reply, i tried the code, it works but it's very slow since i have 50k of data to delete and running everything through a loop simply gonna take forever, i asked a friend to help and here is a faster method for you guys to reference

    PHP Code: 
    Sub Delete_It()
        
    Dim LastRow As Long
        Dim FirstRow 
    As Long
        LastRow 
    Cells(Rows.Count"D").End(xlUp).Row
      
        Application
    .ScreenUpdating False
        
    For 2 To LastRow Step 1
            
    If Cells(i"D") = 0 Then
                Worksheets
    ("Sheet2").Range(Cells(i1), Cells(LastRow4)).Delete
                
    Exit For
            
    End If
        
    Next i
        Application
    .ScreenUpdating True
    End Sub 

+ 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