Macro to Delete a Row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My client is using Excel 2000 in the Windows 2000 O/S. He would like to
create a macro that checks a cell to see if it is empty. If it is empty,
nothing happens, if it is not empty, the entire row is deleted. And then the
next row is checked for the same thing.

Can anyone tell me how to do this?
Thank you,
 
If you look up delete in help, you will find an example that is almost
what you need


This example sorts the data in the first column on Sheet1 and then
deletes rows that contain duplicate data.

Worksheets("Sheet1").Range("A1").Sort _
key1:=Worksheets("Sheet1").Range("A1")
Set currentCell = Worksheets("Sheet1").Range("A1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop


The only difference here is the test - this has nextcell.value being
compared to currentcell.value, you simply need to test
currentcell.value for being blank (len for example would do this)
 

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