Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In a big data set I am trying to find each cell in column J that contains any data so "is not blank", then delete that row that contains data. My code however won't work for it:

Dim rng3 As Range

Do
    Set rng3 = Columns("J:J")
    If Not rng3 Is Nothing Then
        rng.EntireRow.Delete
    Else
        Exit Do
    End If
Loop

I was hoping somebody can help me with this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
684 views
Welcome To Ask or Share your Answers For Others

1 Answer

  1. Select a range you need
  2. Press F5
  3. Press Special... button
  4. Select Constants or Formulas (with other selections, if needed)
  5. Press OK
  6. Now go to: Home -> Cells -> Delete (arrow) -> Delete Sheet Rows

UPDATE

Macros:

Sub DeleteRowsWithData()

    Dim rng As Range

    ' Change to the range you need
    Set rng = Range("A1").CurrentRegion

    ' Change field to the one you need
    rng.AutoFilter Field:=1, Criteria1:="<>", Operator:=xlFilterValues

    With rng
        With .Offset(1).Resize(.Rows.Count - 1) 'Exclude header
            Application.DisplayAlerts = False
            .Rows.Delete
            Application.DisplayAlerts = True
        End With
    End With

End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...