Hello there,
I have a problem with a loop which is supposed to delete rows depending on whether the last column contains blank cells or not. If a cell is blank in the last column, then its respective row has to be deleted.
I'm using this part of the Sub to identify the blank cells in the last column, based on the criteria that I need, and I have no problems with it, it's working fine:
Worksheets("Cash MIS Data").Activate
Dim x As Long
Dim i_column As Long
Dim n_column As Long
n_column = Sheets("Cash MIS Data").Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1).CurrentRegion.Resize(, n_column + 1)
With .Columns(n_column + 1)
.Formula = "=IF(AND(COUNTIF(A:A,LEFT(A1,10)&""*"")>1,RIGHT(A1,3)=""671""),"""",A1)"
.Value = .Value
End With
End With
However, the second part of the code (hereunder) is not working properly, in the sense that it works perfectly for some sheets, but only partially for others: I don't get any error, but I can see from the final result that not all the rows with a blank cell in the last column have been deleted.
Dim i_row As Long
Dim n_row As Long
n_row = Sheets("Cash MIS Data").Cells(Rows.Count, n_column + 1).End(xlUp).Row
With Sheets("Cash MIS Data")
For i_row = 1 To n_row
If .Cells(i_row, n_column + 1).Value = "" Then
.Cells(i_row, n_column + 1).EntireRow.Delete
End If
Next i_row
End With
Columns(n_column + 1).Clear
Is there anything wrong about it?
Bookmarks