+ Reply to Thread
Results 1 to 3 of 3

How to delete rows that are at least 10 words long?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    How to delete rows that are at least 10 words long?

    Please see the excel file attached
    Each row has only a single cell, in each cell there is a short sentence.
    I need a macro that check each cell and delete the entire row if the total amount of words in it is more than 9 words OR if the total amount of characters is more than 79

    Any ideas?

    Thx,
    Sami
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: How to delete rows that are at least 10 words long?

    try it
    Sub ert()
    Dim x, i&, j&
    With Range("A1", Cells(Rows.Count, 1).End(xlUp))
        x = .Value
        For i = 1 To UBound(x)
            If Len(x(i, 1)) <= 79 Then
                If UBound(Split(x(i, 1))) <= 8 Then
                    j = j + 1: x(j, 1) = x(i, 1)
                End If
            End If
        Next i
        .ClearContents: .Resize(j).Value = x
    End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: How to delete rows that are at least 10 words long?

    Thanks a lot Nilem,
    It works!
    Last edited by sami770; 06-12-2012 at 05:39 PM.

+ 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