Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
SITCFanTN
 
Posts: n/a
Default Delete rows if specific criteria not met.

I have a spreadsheet with 8 columns. I want to delete all rows that don't
have the text "Remittance" in column B. I would like to put the code in an
existing macro. Is this very difficult? Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chip Pearson
 
Posts: n/a
Default Delete rows if specific criteria not met.

Try

Dim LastRow As Long
Dim RowNdx As Long
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "B") < "Remittance" Then
Rows(RowNdx).Delete
End If
Next RowNdx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"SITCFanTN" wrote in
message
...
I have a spreadsheet with 8 columns. I want to delete all rows
that don't
have the text "Remittance" in column B. I would like to put
the code in an
existing macro. Is this very difficult? Thanks



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB
 
Posts: n/a
Default Delete rows if specific criteria not met.

One way:

Sub test()
Const strCriteria As String = "remittance"
Dim rngData As Range
Dim rngCell As Range
Dim rngDelete As Range

With Worksheets("Sheet1") '<<<<<Change
Set rngData = Intersect(.UsedRange, .Columns(2))
End With

For Each rngCell In rngData
If LCase(rngCell.Value) < LCase(strCriteria) Then
If rngDelete Is Nothing Then
Set rngDelete = rngCell
Else: Set rngDelete = Union(rngDelete, rngCell)
End If
End If
Next rngCell

If Not rngDelete Is Nothing Then _
rngDelete.EntireRow.Delete

End Sub


"SITCFanTN" wrote:

I have a spreadsheet with 8 columns. I want to delete all rows that don't
have the text "Remittance" in column B. I would like to put the code in an
existing macro. Is this very difficult? Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 54
Default Delete rows if specific criteria not met.

I've done this but don't have the code at home. If you haven't gotten an
answer by tomorrow, I'll copy what I have then.

"SITCFanTN" wrote in message
...
I have a spreadsheet with 8 columns. I want to delete all rows that don't
have the text "Remittance" in column B. I would like to put the code in
an
existing macro. Is this very difficult? 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
Selecting rows based on criteria JCP Excel Discussion (Misc queries) 3 April 5th 06 09:26 AM
resetting last cell jagdish.eashwar Excel Discussion (Misc queries) 11 March 31st 06 02:06 AM
Macro to delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 01:18 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
How to delete blank rows John Mansfield Excel Discussion (Misc queries) 3 April 27th 05 11:48 PM


All times are GMT +1. The time now is 01:44 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"