How to delete empty rows between data

simplyeshu

New Member
Joined
Jun 25, 2011
Messages
30
Hello all,

I am trying to delete empty rows between data. I am using below command but it is deleting complete data. please help

Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Are you trying to delete the entire row or just a specific row in column A?
 
Upvote 0
Hi...!!!! try this..

For i = 1 to 10000
Value = ActiveSheet.Cells(i,1).Value
if Value = "" then
ActiveSheet.Rows(i).delete
Next
 
Upvote 0
Hi...!!!! try this..

For i = 1 to 10000
Value = ActiveSheet.Cells(i,1).Value
if Value = "" then
ActiveSheet.Rows(i).delete
Next
That won't work - you'll upset the counter if you go through them 'top down' - you need to start at the bottom and work up. Also, as a general rule, I'd avoid using reserved words as variable names, and you need an 'end if' so long as your if statement goes over more than 1 line.
Code:
for i = 10000 to 1 step -1
if isempty(cells(i,1)) then rows(i).delete
next
But there's still a problem with this because you need to start where the data ends, rather at an arbitrary row - if the data ends at row 125, you're going to end up deleting 9,875 rows one at a time before you even hit the data.
Code:
for i = cells(rows.count,1).end(xlup).row to 1 step -1
if isempty(cells(i,1)) then rows(i).delete
next
would be better, unless there are rows at the bottom that aren't blank but have nothing in column A.
Trouble is, the OPs original idea should work, unless there are rows where column A is blank and other columns aren't. We need to understand more about the nature of the data itself before answering this one.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top