What's wrong with this code? Please help.

  • Thread starter Thread starter saziz
  • Start date Start date
S

saziz

Hi All,

I am trying to write a code to delete empty cells far a set of data
range:

Sub mysub()
Dim rRange As Range
Set rRange = Sheet1("E1:E150")
With rRange
If cell.Value = "" Then
ActiveCell.Delete shift:=xlUp
End If
End With

End Sub

Appreciate your help.
Thanks
Syed
 
Sub DeleteBlanks()
On Error Resume Next
Range("E1:E150").SpecialCells(xlCellTypeBlanks).Delete (xlShiftUp)
End Sub
 
Jim,
It worked prefectly, Thank you
How can I change it to delete rows instead of cells:
Range("f1:f2950")._SpecialCells_(xlCellTypeBlanks).Delete (xlShiftUp)
^ I want to change this to delete rows


Syed
 
Sub DeleteBlanks()
On Error Resume Next
Range("E1:E150").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
(xlShiftUp)
End Sub
 

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

Back
Top