ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I delete a row in excel if it has no value? (https://www.excelbanter.com/excel-discussion-misc-queries/74705-how-do-i-delete-row-excel-if-has-no-value.html)

CarSum

How do I delete a row in excel if it has no value?
 
I work a lot in spreadsheets that are linked together. Eg I enter data on
one sheet it is recalculated and placed on another spreadsheet that has
multiple rows of data on it. I then delete the lines that have no data from
previous sheet on it to print a neater form. Can I somehow get these rows
that have a zero valu in a certain column not show up when I print instead of
manually deleting them one by one.
Thank You for any help you may be able to give me.

davesexcel

How do I delete a row in excel if it has no value?
 

insert this code in a module
you can make a button and assign the macro to the button
when you highlite a range, run the macro and it will delete the empty
rows


Sub DeleteBlankRows1()
'Deletes the entire row within the selection if the ENTIRE row contains
no data.

'We use Long in case they have over 32,767 rows selected.
Dim i As Long

'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False

'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=518008


bj

How do I delete a row in excel if it has no value?
 
This sounds like a good place for using auto filter
select a column which would be blank for the rows you would not want to show
when printing.
Select non blank from the auto filter options.

"CarSum" wrote:

I work a lot in spreadsheets that are linked together. Eg I enter data on
one sheet it is recalculated and placed on another spreadsheet that has
multiple rows of data on it. I then delete the lines that have no data from
previous sheet on it to print a neater form. Can I somehow get these rows
that have a zero valu in a certain column not show up when I print instead of
manually deleting them one by one.
Thank You for any help you may be able to give me.



All times are GMT +1. The time now is 12:22 AM.

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