Hello all....I have looked but cannot find the answer anywhere for my specific question. I figure it is easy but I cannot crack it.
I want to delete the entire rows between a cell (that will change from one instance to another) and the end of the data I have in the spreadsheet.
What i have below works but deletes row by row and takes forever. I can sort and put all the rows with PN = "" together at the end of the spreadsheet so it is easy to find the first row to delete by going to the end of the data in Column A. The PNs are in Column A.
The variable totalrows used below provides the number of rows with data and is defined earlier in the code and is
[VBA]
totalrows = ActiveSheet.UsedRange.Rows.Count
[/VBA]
Existng Code that takes too long
[VBA]
' Counter to Delete Rows where PN = ""
Dim CounterDelete As Integer
Dim RefPN As String
Range("A1").Select
For CounterDelete = 1 To totalrows
ActiveCell.Offset(1, 0).Select
RefPN = ActiveCell.Value
If RefPN = "" Then
ActiveCell.EntireRow.Select
Selection.Delete
ActiveCell.Offset(-1, 0).Select
Else
'Do Nothing
End If
Next CounterDelete
[/VBA]
Can anyone help me out here ?
Thanks!