Delete Rows

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello One and All

I am using Excel 2003

I have Data in column A to E
I require a VBA macro that will find the last Row in column A that has no data and then delete any data in all the other columns from the blank row in column A
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I require a VBA macro that will find the last Row in column A that has no data
Do you actually mean the first row in column A it comes across that has no data?
 
Upvote 0
Hello One and All

I am using Excel 2003

I have Data in column A to E
I require a VBA macro that will find the last Row in column A that has no data and then delete any data in all the other columns from the blank row in column A

not the best solution
this is will find you the last cell that contain data

=MATCH(REPT("z",255),A:A)

put this code in anywhere else but column A
 
Upvote 0
Perhaps this is what you are looking for.

The following code will start at the very bottom of your sheet and go up column A until it finds the last row that has an entry for column A. It will then select the row just below that, and clear the contents of the entire row.
Code:
Sub MyMacro()
  Rows(Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row).EntireRow.ClearContents
End Sub
 
Upvote 0
Sub ClearRows()
Columns("A").SpecialCells(xlCellTypelanks).EntireRow.Delete
End Sub
 
Upvote 0
When I come to the first blank column in column A I would like to then delete that Row and also any rows below that has any data in any of the other rows but not any data in the rows about the first blank in column A
 
Upvote 0
It sounds like this might do what you want:
Code:
Sub MyMacro()
 
    Dim myFirstRow As Long
    Dim myLastRow As Long
    
'   First first blank row in column A (assuming not at very top)
    myFirstBlankRow = Range("A1").End(xlDown).Offset(1, 0).Row
    
'   First last row on sheet
    myLastRow = Range("A1").SpecialCells(xlLastCell).Row
    
'   Delete all rows start with first blank cell in column A to end of sheet
    Rows(myFirstBlankRow & ":" & myLastRow).EntireRow.Delete
    
End Sub
 
Upvote 0
Hi Sorry I have not come back to you sooner I have been in Iceland on business.
This macro you provided is perfect, thank you so much
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

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
Back
Top