VBA - Deleting empty rows

luporiman

New Member
Joined
Aug 13, 2009
Messages
11
Hello everyone. This is probably a common question, but I am using a VBA macro to convert a .XLS to a .CSV and I need to delete all of the empty rows prior to conversion.

I can find my first empty row with teh macro, but I don't know the syntax to delete from the current row to the end of the document when the first empty row will not always be in the same place.

I greatly appreciate any assistance!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you explain the layout of your data a little bit?
(Are their gaps in your data?)
Maybe describe a simple scenario and which rows you want deleted.
 
Upvote 0
I do this with a command button on my worksheet. You could easily alter it to run before the conversion macro.
Code:
Private Sub CommandButton1_Click()
Dim x As Long
With ActiveSheet
    For x = .Cells.SpecialCells(xlCellTypeLastCell).Row _
        To 1 Step -1
        If WorksheetFunction.CountA(.Rows(x)) = 0 Then
            ActiveSheet.Rows(x).Delete
        End If
    Next
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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