Excel has a powerful filtering capability that lets you view, among other options, the data without blank rows. But how do you remove the blank rows from your data? The following VBA code does the following:
- Select a cell in the maximum row
- Check if the selection is blank
- Delete if blank
- Move up 1 cell
Dim x As Integer
' Set numrows = number of rows of data.
NumRows = 1400 -2
' Select max cell
Range("B1400").Select
' Establish "For" loop to loop "numrows" number of times.
For x = 1 To NumRows
' Insert your code here.
If Selection.Text = "" Then
Selection.EntireRow.Delete
End If
' Selects cell down 1 row from active cell.
ActiveCell.Offset(-1, 0).Select
' Set numrows = number of rows of data.
NumRows = 1400 -2
' Select max cell
Range("B1400").Select
' Establish "For" loop to loop "numrows" number of times.
For x = 1 To NumRows
' Insert your code here.
If Selection.Text = "" Then
Selection.EntireRow.Delete
End If
' Selects cell down 1 row from active cell.
ActiveCell.Offset(-1, 0).Select
There is probably a smarter way to select the maximum number of rows, but for my data it was fixed.