ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AUTOMATIC DELETE (https://www.excelbanter.com/excel-programming/308042-automatic-delete.html)

zebra

AUTOMATIC DELETE
 
Could anyone please tell me how to write a sub() to automatically delete
null numval lines in a sheet viz
sub DelNul()
Dim Cell As Range
For Each Cell In Sheets("'Sheet1").UsedRange
If Sheets("Sheet1").Range(Cell.Address).value - vbNullString Then
Delete Line 'OR SOMETHING LIKE THIS?
Else
End If
Next
End Sub



Tom Ogilvy

AUTOMATIC DELETE
 
Your looping over all cells in the usedrange and if any of them are blank,
deleting the entire row.

if that is what you want to do, simpler would be:

Dim rng as Range
set rng = Sheets("Sheet1").Cells.Specialcells(xlblanks).Enti reRow
if not rng is nothing then
rng.delete
End if

--
Regards,
Tom Ogilvy


"zebra" wrote in message
...
Could anyone please tell me how to write a sub() to automatically delete
null numval lines in a sheet viz
sub DelNul()
Dim Cell As Range
For Each Cell In Sheets("'Sheet1").UsedRange
If Sheets("Sheet1").Range(Cell.Address).value - vbNullString Then
Delete Line 'OR SOMETHING LIKE THIS?
Else
End If
Next
End Sub






All times are GMT +1. The time now is 01:38 AM.

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