FranktheBank
Member
I used the below code to delete blank lines on my spreadsheets. Most times it works great but for some reason this time even if any row in Column A is populated it is deleting that row??
The Code leading up to this point is as follows:
I did read somewhere that the
can be unstable and I'm wondering if somehow, because I am inserting the new Column into the original it's not being considered/read???
Any help would be appreciated.
Code:
Sub DeleteEmptyRowsInActiveSheet()
Dim lngI As Long
For lngI = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If Application.WorksheetFunction.Count(ActiveSheet.Rows(lngI)) = 0 Then
ActiveSheet.Rows(lngI).Delete
End If
Next
End Sub
The Code leading up to this point is as follows:
Code:
Dim lngI As Long
Cells.Select
Selection.UnMerge
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
Rows("1:11").Select
Range("A11").Activate
Selection.Delete Shift:=xlUp
Rows("2:6").Select
Range("A6").Activate
Selection.Delete Shift:=xlUp
Columns("a:a").EntireColumn.Insert
For lngI = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count To 1 Step -1
With Cells(lngI, "A")
If (IsNumeric(Left(Cells(lngI, 2), 4))) Then Range("B" & lngI).Copy Cells(lngI, 1)
End With
Next
I did read somewhere that the
Code:
ActiveSheet.UsedRange.Row
Any help would be appreciated.