Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to delete blank rows 2

Status
Not open for further replies.

Chuck712

Technical User
Mar 1, 2002
133
US
I have a spreadsheet that gets its data from a .pdf document report. I have been able to reduce this to get the data I need into 2 separate columns, but I have numerous blank rows with no data that I need to eliminate before I proceed. Without going through and manually deleting all of those rows, has anyone used anything to copy the sheet to another sheet and eliminate those balnk rows?
Thanks
 
Hi Chuck712,

I just recorded this macro. It selects your two columns, filters them to hide blank cells in column A and copies the remaining values to the first two columns of another sheet. I'm sure you can tweak it to fit your exact needs.

Code:
Sub Macro1()
Code:
'
' Macro1 Macro
' Macro recorded 13/05/2003 by Tony Jollans
'

'
Code:
    Columns("A:B").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:=&quot;<>&quot;, Operator:=xlAnd
    Selection.Copy
    Sheets(&quot;Sheet2&quot;).Select
    Range(&quot;A1&quot;).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
End Sub

Enjoy,
Tony
 
Thanks. This works great. Still need to &quot;tweak&quot; that screwy input data, but this is a life saver
 
As long as they were truly blank, this will delete all completely blank rows:-

Sub DeleteEmptyRows()
'John Walkenbach
'Will delete all rows that are entirely blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

Regards
Ken...............
 
You can use the macro, but here's the &quot;easy&quot;, non-VBA way:

Select the column that will ALWAYS have data if there's a record in that row. It's usually, but not always, column A.

So, select the column.
Hit Edit-Go to-Special, choose Blanks, hit OK.
Hit Edit-Delete.
You'll be asked to move cells up/whatever. Choose Delete Entire Row.

Anne Troy
Word and Excel Macros
Coming soon: wX
 
Dreamboat,

There is still so much I don't know. I did realise after I posted that this is not the VBA forum and that maybe code wasn't wanted but by the time I came back Chuck seemed happy so I left it, but your solution is better than mine.

Have a star for helping me learn.

Thanks,
Tony
 
Thanks to all of you. I used all three methods. And it helped a great deal. The non-VBA way was a little quicker.
Thank Again
Chuck
 

Hey Dreamboat.

Thanks for the non VBA solution, that help alot!

Similar question, I am importing a report via Document Direct that includes blank rows and header info from each page of the mainframe report. Any ideas on how to modify this spreadsheet in the fewest steps? There is one column that contains 2 character values so i thought a macro might be possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top