Need a Macro to remove "blank lines"

Traderdave

New Member
Joined
Oct 22, 2008
Messages
7
I have a spreadsheet that contains over 80,000 lines of data. The lines of data are seperated by a repeated column heading on the page breaks, as well as 2 or 3 lines, (it varies), in between the necessary information. I need to figure out how to remove the column headings, (of which there are approximately 10,000 lines), as well as the blank lines between the data. I can not sort on a specific line and then delete the unnecessary data as when I do this cell "A2" loses its relationship with Cells "C2", "C3" and "C4". is there a Macro, ( or another easy way), to do this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this on a copy of your data. Change 'Your column header' in the code to the actual text in the header rows you want to get rid of. Also change the 3 in the statement 'For i = LR To 3 Step -1' to whatever number of rows you want to keep at the top of your sheet
Code:
Sub Delete()
Application.ScreenUpdating = False
      Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 3 Step -1
    If Range("A" & i).Value = "Your column header" Or Range("A" & i).Value = "" Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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