Delete Rows Based on Words

C

Cue

I'm trying to delete rows that 'Immediate Refund' in the cells of a column. I
have a formula but it does not work. Can someone help me with this?

Sub Delete_N_MarkedRows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim lastrow As Long, r As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For r = lastrow To 1 Step -1
If UCase(Cells(r, 6).Value) = "Immediate Refund" Then Rows(r).Delete
Next r
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
J

Jim Cone

This line...
If UCase(Cells(r, 6).Value) = "Immediate Refund" Then Rows(r).Delete
Resolves to...
If IMMEDIATE REFUND = "Immediate Refund" Then Rows(r).Delete

You could change the lower case "Immediate Refund" to upper case
and probably get it to work.
-Or-
Add Option Compare Text to the top of the module
-Or-
Use the StrComp function...
If StrComp(Cells(r, 6).Text, "Immediate Refund", 1) = 0 Then Rows(r).Delete
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Cue" <[email protected]>
wrote in message
I'm trying to delete rows that 'Immediate Refund' in the cells of a column. I
have a formula but it does not work. Can someone help me with this?

Sub Delete_N_MarkedRows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim lastrow As Long, r As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
For r = lastrow To 1 Step -1
If UCase(Cells(r, 6).Value) = "Immediate Refund" Then Rows(r).Delete
Next r
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top