G
Guest
I would like some help in deleting a block of rows that have blank values in
columns B and C. I have code that will loop through each of the cells,
however this is time consuming with large worksheets.
The code snippet below gives me the count of rows I want to keep and the
count of rows I want to delete. My thought was to store the counts into the
two variables (cntrMTNo,cntrMTYes) and try and pass the variable values into
a range or row statement for deleting. Any help would be greatly
appreciated. Thanks
*************************************************************
Dim cntrMTNo As Integer
Dim cntrMTYes As Integer
Range("A7").Select
Do Until ActiveCell.Offset(0, 1) = "TOTAL:"
If Not IsEmpty(ActiveCell.Offset(0, 1)) And Not
IsEmpty(ActiveCell.Offset(0, 2)) Then
cntrMTNo = cntrMTNo + 1
End If
ActiveCell.Offset(1, 0).Select
Loop
Range("A7").Select
Do Until ActiveCell.Offset(0, 1) = "TOTAL:"
If IsEmpty(ActiveCell.Offset(0, 1)) And IsEmpty(ActiveCell.Offset(0, 2))
Then
cntrMTYes = cntrMTYes + 1
End If
ActiveCell.Offset(1, 0).Select
Loop
************************************************************
'Rows("11:37").Select
'Selection.Delete Shift:=xlUp
columns B and C. I have code that will loop through each of the cells,
however this is time consuming with large worksheets.
The code snippet below gives me the count of rows I want to keep and the
count of rows I want to delete. My thought was to store the counts into the
two variables (cntrMTNo,cntrMTYes) and try and pass the variable values into
a range or row statement for deleting. Any help would be greatly
appreciated. Thanks
*************************************************************
Dim cntrMTNo As Integer
Dim cntrMTYes As Integer
Range("A7").Select
Do Until ActiveCell.Offset(0, 1) = "TOTAL:"
If Not IsEmpty(ActiveCell.Offset(0, 1)) And Not
IsEmpty(ActiveCell.Offset(0, 2)) Then
cntrMTNo = cntrMTNo + 1
End If
ActiveCell.Offset(1, 0).Select
Loop
Range("A7").Select
Do Until ActiveCell.Offset(0, 1) = "TOTAL:"
If IsEmpty(ActiveCell.Offset(0, 1)) And IsEmpty(ActiveCell.Offset(0, 2))
Then
cntrMTYes = cntrMTYes + 1
End If
ActiveCell.Offset(1, 0).Select
Loop
************************************************************
'Rows("11:37").Select
'Selection.Delete Shift:=xlUp