+ Reply to Thread
Results 1 to 4 of 4

Delete rows without deleting title row using a loop

Hybrid View

Sacharny Delete rows without deleting... 05-01-2013, 12:49 PM
AndyLitch Re: Delete rows without... 05-01-2013, 12:54 PM
Sacharny Re: Delete rows without... 05-01-2013, 12:57 PM
AndyLitch Re: Delete rows without... 05-01-2013, 01:00 PM
  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    26

    Delete rows without deleting title row using a loop

    Hi, thank you in advance for any help!

    I am trying to delete all rows that have a value equal or greater than zero on Column J. For some weird reason the macro is also deleting the title row! The title row has only words and letters. Column J's title is WEB. Could anyone help me figure out what is wrong with my code? Here it is:

    Sub DeleteRows()
    
    Dim i As Long
    
    For i = Cells(Rows.Count, "J").End(xlUp).row To 1 Step -1
    
        If Cells(i, "J").Value >= 0 Then Cells(i, "J").EntireRow.Delete
      Next i
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Delete rows without deleting title row using a loop

    Change this

    For i = Cells(Rows.Count, "J").End(xlUp).row To 1 Step -1
    To this

    For i = Cells(Rows.Count, "J").End(xlUp).row To 2 Step -1
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Delete rows without deleting title row using a loop

    Perfect, it works! Thank you!

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Delete rows without deleting title row using a loop

    Anytime..........

+ 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