ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting lines with no data (https://www.excelbanter.com/excel-programming/284947-deleting-lines-no-data.html)

Paulo Gonçalves

Deleting lines with no data
 
I'm a newbie in excel and i want to now how can i delete a
full line in excel that have no data on it, From line 1 to
400 (Supose) i'm trying to make a code that choose all the
lines that have no data and automatic select and delete
them.

Help should be apreciated....Thank you!!

Vasant Nanavati

Deleting lines with no data
 
Something like (untested):

Sub DeleteBlankRows()
Dim i As Long, rng As Range
For i = 1 To 400
If WorksheetFunction.CountA(Rows(i)) = 0 Then
If rng Is Nothing then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
End If
Next
rng.Delete
End Sub

--

Vasant


"Paulo Gonçalves" wrote in message
...
I'm a newbie in excel and i want to now how can i delete a
full line in excel that have no data on it, From line 1 to
400 (Supose) i'm trying to make a code that choose all the
lines that have no data and automatic select and delete
them.

Help should be apreciated....Thank you!!




Robin Hammond[_2_]

Deleting lines with no data
 
Vasant's approach will work perfectly well for 99% of cases in a simple
book. If you are looking for a more complex solution there's a routine in my
XspandXL add-in on the site below that does this for rows and or columns
while also checking for charts and other shapes, and dealing with any hidden
rows or outlining in the sheet.

Robin Hammond
www.enhanceddatasystems.com


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Something like (untested):

Sub DeleteBlankRows()
Dim i As Long, rng As Range
For i = 1 To 400
If WorksheetFunction.CountA(Rows(i)) = 0 Then
If rng Is Nothing then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
End If
Next
rng.Delete
End Sub

--

Vasant


"Paulo Gonçalves" wrote in message
...
I'm a newbie in excel and i want to now how can i delete a
full line in excel that have no data on it, From line 1 to
400 (Supose) i'm trying to make a code that choose all the
lines that have no data and automatic select and delete
them.

Help should be apreciated....Thank you!!







All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com