PDA

View Full Version : [SOLVED:] Deleting empty rows



Veeru
07-26-2017, 10:04 AM
Hi,

this is simple I guess for you guys but what I need is my code to find last empty row and then delete next 50 blank rows.

Like if my last empty row is A10 then code should take me to A11 and then delete empties rows from A11 till A61.

This looks crazy , why we want to delete empty rows but yes I need it for certain purposes.

below code is to find empty row. can anyone look into the same please
Sub test()
With Application.WorksheetFunction
Cells(.CountA(Columns("A:A")) + 1, 1).Select
End With
End Sub

YasserKhalil
07-26-2017, 10:54 AM
Hello
Please put the code between code tags
May be


Sub Test()
Dim lr As Long

lr = Cells(Rows.Count, 1).End(xlUp).Row + 1

Range("A" & lr).Resize(50).EntireRow.Delete
End Sub

Veeru
07-26-2017, 11:39 AM
This is not working...I have formulas in these empty rows...attaching one sample file...Name is Var

YasserKhalil
07-26-2017, 11:49 AM
Try this code


Sub Test()
Dim lr As Long

lr = Range("A:A").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Range("A" & lr).Resize(50).EntireRow.Delete
End Sub

Veeru
07-26-2017, 11:53 AM
Great it is working...thank you so much

YasserKhalil
07-26-2017, 11:55 AM
You're welcome. Glad I can offer some help
Please mark the thread as solved

elsuji
09-01-2019, 06:47 AM
Is this possible to input the multiple sheet name on this code