Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Delete Rows Based on Words

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
--
Cue
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Delete Rows Based on Words


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"
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
--
Cue
  #3   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default Delete Rows Based on Words

Thanks for your help!
--
Cue


"Jim Cone" wrote:


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"
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
--
Cue

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete rows based on a condition Darrilyn Excel Worksheet Functions 1 September 6th 07 12:12 AM
Delete rows based on criteria Chris_t_2k5 Excel Discussion (Misc queries) 2 April 11th 06 01:52 PM
Delete rows based on certain criteria Coal Miner Excel Discussion (Misc queries) 2 March 3rd 06 06:56 PM
Besides manually how can I delete words in multiple rows? Kelly P. Excel Discussion (Misc queries) 2 November 29th 05 03:11 PM
Delete rows based on multiple criterias Benson Excel Discussion (Misc queries) 8 November 2nd 05 04:11 PM


All times are GMT +1. The time now is 05:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"