+ Reply to Thread
Results 1 to 5 of 5

Delete Rows w. Multiple Space

Hybrid View

  1. #1
    Registered User
    Join Date
    02-26-2004
    Location
    philippines
    Posts
    73

    Delete Rows w. Multiple Space

    Hi Guys,

    I need a macro to delete rows with spaces greater than 20. I don't know how excel define a space so I'm not sure where to start.

    Can anyone help with this one? Thanks!
    Last edited by japorms; 11-16-2009 at 12:52 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Delete Rows w. Multiple Space

    Why not post an example workbook which has examples of what you mean by 20 spaces.

    Include both types of rows and let us know which you think should be deleted.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    02-26-2004
    Location
    philippines
    Posts
    73

    Re: Delete Rows w. Multiple Space

    Here's a sample
    Attached Files Attached Files

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Delete Rows w. Multiple Space

    try this,

    Sub X()
    
        Dim lngRow As Long
        
        With ActiveSheet
            For lngRow = .Cells(.Rows.Count, 1).End(xlUp).Row To 1 Step -1
                If Len(.Cells(lngRow, 1)) > 0 Then
                    If Len(Trim(Left(.Cells(lngRow, 1), 20))) = 0 Then
                        .Cells(lngRow, 1).EntireRow.Delete
                    End If
                End If
            Next
        End With
            
    End Sub

  5. #5
    Registered User
    Join Date
    02-26-2004
    Location
    philippines
    Posts
    73

    Re: Delete Rows w. Multiple Space

    Thanks! It work perfectly.

    I'll study this code.

+ 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