ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Deleting Rows using Macros (https://www.excelbanter.com/excel-discussion-misc-queries/39249-deleting-rows-using-macros.html)

bernard

Deleting Rows using Macros
 
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.

Bernie Deitrick

bernard,

Sub DeleteRows()
Range("D:D").SpecialCells(xlCellTypeBlanks).Entire Row.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


"bernard" wrote in message
...
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.




bernard

Excellent, worked a treat! Thanks again.

"Bernie Deitrick" wrote:

bernard,

Sub DeleteRows()
Range("D:D").SpecialCells(xlCellTypeBlanks).Entire Row.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


"bernard" wrote in message
...
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.





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



--
Regards Ron de Bruin
http://www.rondebruin.nl


"bernard" wrote in message ...
Excellent, worked a treat! Thanks again.

"Bernie Deitrick" wrote:

bernard,

Sub DeleteRows()
Range("D:D").SpecialCells(xlCellTypeBlanks).Entire Row.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


"bernard" wrote in message
...
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.








All times are GMT +1. The time now is 03:22 PM.

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