Hi,
I have a routine that deletes rows when the ammount of characters in cell "C & row" is less than 9 characters. This works fine.
I now have to throw in a condition to this rule, whereby the row only gets deleted if the prefix of the cell "C & row" matches a certain character. If it does match that character then the check for less than 9 characters needs to run and delete the row accoringly. I hope this makes sense to somebody? The code below may help...
Basically, the "deleting row if cell (c & row) is less than 9 characters" only needs to happen if the prefix of cell (c & row) is ME or BP...
HELP!
Thanks in advance
Alan
I have a routine that deletes rows when the ammount of characters in cell "C & row" is less than 9 characters. This works fine.
I now have to throw in a condition to this rule, whereby the row only gets deleted if the prefix of the cell "C & row" matches a certain character. If it does match that character then the check for less than 9 characters needs to run and delete the row accoringly. I hope this makes sense to somebody? The code below may help...
Code:
Sub delrow()
Dim rcount, rloop
' Deletes the rows where the Field code is blank, or less than 3 characters
rcount = Sheets("sheet1").UsedRange.Rows.Count
For rloop = rcount To 2 Step -1
If Left(Range("C" & rloop).Value, 2) = "BP" Then
'MsgBox ("anything")
If Len(Range("C" & rloop).Value) < 9 Then
MsgBox ("anything")
Rows(rloop).Delete Shift:=xlUp
End If
End If
If Left(Range("C" & rloop).Value, 2) = "ME" Then
If Len(Range("C" & rloop).Value) < 9 Then
Rows(rloop).Delete Shift:=xlUp
End If
End If
Next
End Sub
Basically, the "deleting row if cell (c & row) is less than 9 characters" only needs to happen if the prefix of cell (c & row) is ME or BP...
HELP!
Thanks in advance
Alan