Macro for Deleting rows with balnk cell

  • Thread starter Radhakant Panigrahi
  • Start date
R

Radhakant Panigrahi

Hi,

i have several data in a sheet with data in 10 columns...

in column A there are cells where it is blank and i want to delete the rows
where there is blank cell in column A..
I need the vba macro for this

regards,
radha
 
R

Ron de Bruin

Try

Sub DeleteBlankRows_2()
'This macro delete all rows with a blank cell in column A
'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("A") ' You can also use a range like this Range("A1:A8000")
CCount = .SpecialCells(xlCellTypeBlanks).Areas(1).Cells.Count
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
 
G

Gord Dibben

Turn on macro recorder.

Select column A and F5>Special>Blanks>OK

Edit>Delte>Entire row.

The recorder gives you this.

Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top