Thread: URGENT LOOP ?
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default URGENT LOOP ?

I would like to Delete the Receipt number and the subtotal for the receipt
number

"Mike H" wrote:

Mike,

What do you think is wrong with this. It reads up the used range of columnn
B and if the last 5 characters are "Total" and the value in the corresponding
row of column C is less than 5 the entirerow is deleted assuming of course
the delete line is un-commented. Is that what you expect to happen?

Mike

"Mike" wrote:

I have a sheet that is Subtotaled by Receipts #'s I'm trying to delete
Receipts that are less then 5
Please help
Sub deleterowtest()
Dim rngColB As Range
Dim ipointer As Long
Dim sSting As String
sSting = "Total"
'Change "B" to the column your data in in you are looking to find
Set rngColB = ActiveSheet.Range(Cells(1, "B"), Cells(Rows.Count,
"B").End(xlUp))

'Work backwards from bottom to top when deleting rows
With rngColB
For ipointer = .Rows.Count To 1 Step -1
If Right(.Cells(ipointer).Value, 5) = (sSting) And _
.Cells(ipointer).Offset(0, 1).Value < 5 Then
MsgBox .Cells(ipointer).Offset(0, 1).Value
'.Cells(ipointer).EntireRow.Delete
End If
Next ipointer
End With
End Sub