Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8327383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:05:29+00:00 2026-06-09T01:05:29+00:00

I have been trying to use some snippets on how to delete entire rows

  • 0

I have been trying to use some snippets on how to delete entire rows on Excel VBA, but I can’t modify them to include the “IsNumber” verification.

I need to be able to choose an active area, like:

Set r = ActiveSheet.Range("A1:C10")

And as it goes through row after row (and checking every cell of the area), delete the entire row if a there is a number on a cell.

For example:

NA NA NA 21
NA 22 NA 44
00 NA NA NA
NA NA NA NA
55 NA NA NA

The macro would then delete all the rows, except for the 4th one which is

NA NA NA NA
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:05:30+00:00Added an answer on June 9, 2026 at 1:05 am

    Take your pick 🙂

    WAY 1 (TRIED AND TESTED)

    This uses SpecialCells to identify the rows which has numbers.

    Sub Sample()
        Dim ws As Worksheet
        Dim rng As Range
    
        On Error GoTo Whoa
    
        Set ws = Sheets("Sheet1")
    
        With ws
            Set rng = .Cells.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow
    
            rng.ClearContents '<~~ or rng.Clear if cells have formatting
    
            .Cells.Sort Key1:=.Range("A1")
        End With
    
        Exit Sub
    Whoa:
        MsgBox Err.Description
    End Sub
    

    WAY 2 (TRIED AND TESTED)

    This uses Looping and Count() to check for numbers

    Sub Sample()
        Dim ws As Worksheet
        Dim delrange As Range
        Dim lRow As Long, i As Long
    
        On Error GoTo Whoa
    
        Set ws = Sheets("Sheet1")
    
        With ws
            lRow = .Range("A" & .Rows.Count).End(xlUp).Row
    
            For i = 1 To lRow
                If Application.WorksheetFunction.Count(.Rows(i)) > 0 Then
                    If delrange Is Nothing Then
                        Set delrange = .Rows(i)
                    Else
                        Set delrange = Union(delrange, .Rows(i))
                    End If
                End If
            Next i
    
            If Not delrange Is Nothing Then delrange.Delete
        End With
    
        Exit Sub
    Whoa:
        MsgBox Err.Description
    End Sub
    

    Way 3 (TRIED AND TESTED)

    This uses Auto Filters. I am assuming that row 1 has headers and there is no blank cell in your range.

    Sub Sample()
        Dim ws As Worksheet
        Dim lRow As Long, lCol As Long, i As Long
        Dim ColN As String
    
        On Error GoTo Whoa
    
        Set ws = Sheets("Sheet1")
    
        With ws
            lRow = .Range("A" & .Rows.Count).End(xlUp).Row
            lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    
            For i = 1 To lCol
                '~~> Remove any filters
                .AutoFilterMode = False
                ColN = Split(.Cells(, i).Address, "$")(1)
    
                '~~> Filter, offset(to exclude headers) and delete visible rows
                With .Range(ColN & "1:" & ColN & lRow)
    
                    .AutoFilter Field:=1, Criteria1:=">=" & _
                    Application.WorksheetFunction.Min(ws.Columns(i)), _
                    Operator:=xlOr, Criteria2:="<=" & _
                    Application.WorksheetFunction.Max(ws.Columns(i))
    
                    .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
                End With
    
                '~~> Remove any filters
                .AutoFilterMode = False
            Next
        End With
    
        Exit Sub
    Whoa:
        MsgBox Err.Description
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to use Prototype to do some DOM manipulation, but I
I have been trying to use localstorage to store Jquery-min but I am unable
I have been trying to use some custom fonts within my WP7 app. I
I have been trying to use cx_freeze for some time now, and yet the
i have been trying to use some ajax to save venue location in my
For the last few days, I have been trying to use Python for some
I have been trying to use some objective C, i have got as far
I have been trying for some days to use the channel.send_message API in GAE
I have been trying to use the SAX parser on Android to display some
I have been trying to use django-allauth to provide Social registration, but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.