Delete entire row

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
858
Hi all, i would like to use VBA code so that to delete entire row, where in column "A" is number. Due to headings the code should run from "A4" and rows down. Thank you all in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,180
Code:
[COLOR=#008000]'Declare sheet[/COLOR]
 Dim sh As Worksheet: Set sh = ActiveSheet
[COLOR=#008000]'Declare last row[/COLOR]
 Dim lr As Long: lr = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row
[COLOR=#008000]'Declare running row[/COLOR]
 Dim r As Long
[COLOR=#008000]'Loop through rows[/COLOR]
 For r = lr To 4 Step (-1)
    If IsNumeric(Cells(r, 1).Value) Then
        Rows(r).Delete
    End If
 Next r
 
Last edited:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,866
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Does this macro do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub DeleteRowsIfNumbersInColumnA()
  Columns("A").SpecialCells(xlConstants, xlNumbers).EntireRow.Delete
End Sub[/td]
[/tr]
[/table]
 

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
858
Many thanks Kamolga, the code works perfect. Thanks also for your time spent for my project. Hv a great day
 

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
858
Thank you Rick, the VBA works nicely. Thansk once again for your continued support. Hv a lovely day
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,600
Messages
5,832,651
Members
430,151
Latest member
Kacbear

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top