Deleting Rows using Macros

B

bernard

I need to format a sheet every month into a format that can be imported into
our accounting system - I plan to do this using macros.

The sheet contains a number of rows that are not to be imported into the
system and I wish to delete these - the rows to be deleted are those where
column D contains no value.

The spreadsheet has a different number of rows each month. Can anyone advise
how this can best be done.

Thanks in advance.
 
B

Bernie Deitrick

bernard,

Sub DeleteRows()
Range("D:D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

This will only work if the cells are truly blank - not filled with a formula that returns "".

HTH,
Bernie
MS Excel MVP
 
B

bernard

Excellent, worked a treat! Thanks again.

Bernie Deitrick said:
bernard,

Sub DeleteRows()
Range("D:D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

This will only work if the cells are truly blank - not filled with a formula that returns "".

HTH,
Bernie
MS Excel MVP
 
R

Ron de Bruin

I like to add this

Use a on error in the code, this avoid a error if there are no blanks

On Error Resume Next

' code

On Error GoTo 0

Note: The limit of SpecialCells is 8192 separate areas
 
Top