Consolidating non-blank rows from a 2d range

daabs

New Member
Joined
Feb 25, 2007
Messages
3
I have a 2d range which has some blank rows in it. I would like to be able to take the non-blank rows and consolidate them as a contiguous block in another range without disturbing the original table.

Any ideas, anyone?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
you can try this. there's no copy to column procedure (since you didn't mention where it was to be copied). so, you can copy the data to the column of your choosing the run the below macro. note: the below macro uses defaults (ie. Sheet1, Column A) so you'll have to change those to the sheet you want and the column letter you want.

Code:
Sub DeleteBlanks()

Dim LR As Long, i As Long

LR = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

For i = LR To 1 Step -1
    If Range("A" & i) = "" Then
       Range("A" & i).Delete Shift:=xlUp
    End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,123,005
Members
449,092
Latest member
masterms

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