PC Review


Reply
Thread Tools Rate Thread

Deleting rows based on a cell value

 
 
vkaur09@gmail.com
Guest
Posts: n/a
 
      6th Nov 2006
Hi,

I need to delete all the rows in a worksheet which match a particular
value in a column. Below is a sample of the sheet:
Partner# Name Customer#

A_NOVATION ABBOTT NOVATION 26967
B_NOVATION BOSTON NOVATION 26967
A_PREMIER ABBOTT PREMIER 26968
B_PREMIER BOSTON PREMIER 26968
A_BROADLAN ABBOTT BROADLANE 26969
B_BROADLAN BOSTON BROADLANE 26969
A_BROADLAN ABBOTT BROADLANE 26971
B_BROADLAN BOSTON BROADLANE 26971
A_BROADLAN ABBOTT BROADLANE 26972
B_BROADLAN BOSTON BROADLANE 26972
A_NOVATION ABBOTT NOVATION 26973
B_NOVATION BOSTON NOVATION 26973
MEDASSETS MEDASSETS HSCA INC 26974
A_NOVATION ABBOTT NOVATION 26975
B_NOVATION BOSTON NOVATION 26975
A_HEALTHTR ABBOTT HEALTHTRUST 26977
B_HEALTHTR BOSTON HEALTHTRUST 26977

So basically i want to delete all the rows for which column 1 has a
value starting with A_.
Can anyone help me with this?

Thanks

 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      6th Nov 2006
You can try this for column A
A1 = the header cell

Sub Delete_with_Autofilter()
Dim DeleteValue As String
Dim rng As Range

DeleteValue = "A"
With ActiveSheet
.Range("A:A").AutoFilter Field:=1, Criteria1:=DeleteValue & "*"
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi,
>
> I need to delete all the rows in a worksheet which match a particular
> value in a column. Below is a sample of the sheet:
> Partner# Name Customer#
>
> A_NOVATION ABBOTT NOVATION 26967
> B_NOVATION BOSTON NOVATION 26967
> A_PREMIER ABBOTT PREMIER 26968
> B_PREMIER BOSTON PREMIER 26968
> A_BROADLAN ABBOTT BROADLANE 26969
> B_BROADLAN BOSTON BROADLANE 26969
> A_BROADLAN ABBOTT BROADLANE 26971
> B_BROADLAN BOSTON BROADLANE 26971
> A_BROADLAN ABBOTT BROADLANE 26972
> B_BROADLAN BOSTON BROADLANE 26972
> A_NOVATION ABBOTT NOVATION 26973
> B_NOVATION BOSTON NOVATION 26973
> MEDASSETS MEDASSETS HSCA INC 26974
> A_NOVATION ABBOTT NOVATION 26975
> B_NOVATION BOSTON NOVATION 26975
> A_HEALTHTR ABBOTT HEALTHTRUST 26977
> B_HEALTHTR BOSTON HEALTHTRUST 26977
>
> So basically i want to delete all the rows for which column 1 has a
> value starting with A_.
> Can anyone help me with this?
>
> Thanks
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows based on values in a a cell in the row Martin Microsoft Excel New Users 1 25th Jan 2009 11:46 AM
Deleting rows based on a cell value JPriest Microsoft Excel Worksheet Functions 3 12th Aug 2005 05:44 PM
Deleting rows based on cell criteria =?Utf-8?B?amdyYW5kYQ==?= Microsoft Excel Programming 1 27th Apr 2004 06:41 PM
Deleting rows based on cell is empty Todd Microsoft Excel Programming 14 11th Mar 2004 02:28 PM
Deleting Rows based on text in cell & formatting cell based on text in column beside it =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 4 26th Feb 2004 03:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:27 PM.