Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Delete Row Help



I am trying to have a macro that will delete any row where B is not
"Pending." My code below is giving an error on line: If (cell.Value)
< "Pending" Then

Can you troubleshoot? Thanks.

A B C D
10/18/2006 9:39 Pending 34 Local Area Activity
11/20/2006 9:44 Completed 1 Local Area Activity
11/20/2006 9:59 Pending 2 Local Area Activity

Sub Only_Pending()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("B:B"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < "Pending" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
On Error Resume Next
del.EntireRow.Delete
'
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete Row Help

Try

If cell.Value < "Pending" Then

See also the union example on this page
http://www.rondebruin.nl/delete.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ps.com...


I am trying to have a macro that will delete any row where B is not
"Pending." My code below is giving an error on line: If (cell.Value)
< "Pending" Then

Can you troubleshoot? Thanks.

A B C D
10/18/2006 9:39 Pending 34 Local Area Activity
11/20/2006 9:44 Completed 1 Local Area Activity
11/20/2006 9:59 Pending 2 Local Area Activity

Sub Only_Pending()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("B:B"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < "Pending" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
On Error Resume Next
del.EntireRow.Delete
'
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Delete Row Help

On Jul 11, 1:33 pm, "Ron de Bruin" wrote:
Try

If cell.Value < "Pending" Then

See also the union example on this pagehttp://www.rondebruin.nl/delete.htm

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

wrote in glegroups.com...

I am trying to have a macro that will delete any row where B is not
"Pending." My code below is giving an error on line: If (cell.Value)
< "Pending" Then


Can you troubleshoot? Thanks.


A B C D
10/18/2006 9:39 Pending 34 Local Area Activity
11/20/2006 9:44 Completed 1 Local Area Activity
11/20/2006 9:59 Pending 2 Local Area Activity


Sub Only_Pending()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("B:B"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < "Pending" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
On Error Resume Next
del.EntireRow.Delete
'
End Sub


I used another of your examples, and got it to work. thanks.

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 sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 04:38 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 12:04 PM.

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

About Us

"It's about Microsoft Excel"