ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete empty rows from a sheet (https://www.excelbanter.com/excel-programming/363313-delete-empty-rows-sheet.html)

bm4466[_5_]

Delete empty rows from a sheet
 

Hey could anybody help me with a script for deleting a row from a sheet
if its second column is empty?

I would appreciate it, Ben


--
bm4466
------------------------------------------------------------------------
bm4466's Profile: http://www.excelforum.com/member.php...o&userid=33949
View this thread: http://www.excelforum.com/showthread...hreadid=548594


Ron de Bruin

Delete empty rows from a sheet
 
Hi bm4466

Try
http://www.rondebruin.nl/specialcells.htm

Sub DeleteBlankRows_2()
'This macro delete all rows with a blank cell in column B
'If there are no blanks or there are too many areas you see a MsgBox
Dim CCount As Long
On Error Resume Next

With Columns("B") ' You can also use a range like this Range("A1:A8000")

CCount = .SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Cou nt

If CCount = 0 Then
MsgBox "There are no blank cells"
ElseIf CCount = .Cells.Count Then
MsgBox "There are more then 8192 areas"
Else
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If

End With

On Error GoTo 0
End Sub


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



"bm4466" wrote in message
...

Hey could anybody help me with a script for deleting a row from a sheet
if its second column is empty?

I would appreciate it, Ben


--
bm4466
------------------------------------------------------------------------
bm4466's Profile: http://www.excelforum.com/member.php...o&userid=33949
View this thread: http://www.excelforum.com/showthread...hreadid=548594




pianoman[_44_]

Delete empty rows from a sheet
 

rnum = 'insert start row number here

Range("A" & rnum).select
while activecell <""
do
if activecell.offset(0,1) = "" then
entirerow.delete
else
rnum = rnum + 1
end if
Range("A" & rnum).select
loop until activecell = ""
Wend


bm4466 Wrote:
Hey could anybody help me with a script for deleting a row from a sheet
if its second column is empty?

I would appreciate it, Ben



--
pianoman
------------------------------------------------------------------------
pianoman's Profile: http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=548594



All times are GMT +1. The time now is 01:43 PM.

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