#1   Report Post  
barrfly
 
Posts: n/a
Default filter a list


I have a list in a column with approx. 10,000 records - call these deal
IDS. I want to remove the occurence of several of these ids either
with an advanced filter or a quick subroutine.

my dealIDs that I want to have removed are in a list on another
worksheet. there are about 50 dealsIDS that occur 4 to 5 times in the
list.

Now, I know I can write a vlook up to identify these deal ids to remove
and I know that I can sort them out but the goal is to create a filter
that can read the deal ID list (which will change) and remove the
records with those ids on the other tab.

suggestions??


--
barrfly

Excel User - Energy markets
------------------------------------------------------------------------
barrfly's Profile: http://www.excelforum.com/member.php...fo&userid=4141
View this thread: http://www.excelforum.com/showthread...hreadid=472790

  #2   Report Post  
Zack Barresse
 
Posts: n/a
Default

Well, I'd suggest a VBA routine to do this. Could get it in one fell-swoop.
If you want an example, we have to assume a few things first...

1) your data table is in 'Sheet1'
2) your deal ID's are in 'Sheet2' and in column A starting at row 2
3) your data table had single row headers
4) your data table extends from A1 to Dx (where x is a variable row number,
dependent upon column A's last row)
5) assumed column D is the extent of your table, can be adjusted as
necessary

Assuming this, you can perform these steps:

1) Hit Alt + F11, enter the Visual Basic Editor (VBE).
2) Hit Ctrl + R, open the Project Explorer.
3) Select Insert (menu) | Module.
4) Paste the below code in the module (right {white/blank} pane).
5) Hit Alt + Q, return to Excel.
6) Save before anything is done.
7) Hit Alt + F8, select DeleteDealID and select Run.

Code:


Option Explicit
Sub DeleteDealID()

Dim wsID As Worksheet, wsTable As Worksheet
Dim rngID As Range, rngLoop As Range
Dim LastRow As Long, i As Long
Dim strID As String

Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False

Set wsID = Sheets("Sheet2") 'set as desired
Set wsTable = Sheets("Sheet1") 'set as desired

With wsTable

LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set rngID = .Range("A2:A" & LastRow)

If .AutoFilterMode Then .Cells.AutoFilter

On Error Resume Next '(for SpecialCells)
For i = 2 To wsID.Cells(Rows.Count, "A").End(xlUp).Row Step 1
strID = wsID.Cells(i, "A").Text
.Range("A1:A" & LastRow).AutoFilter 1, strID
Intersect(rngID, rngID.SpecialCells(xlCellTypeVisible)).Delete
Next i

.Cells.AutoFilter

End With

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True

End Sub



HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)



"barrfly" wrote in
message ...

I have a list in a column with approx. 10,000 records - call these deal
IDS. I want to remove the occurence of several of these ids either
with an advanced filter or a quick subroutine.

my dealIDs that I want to have removed are in a list on another
worksheet. there are about 50 dealsIDS that occur 4 to 5 times in the
list.

Now, I know I can write a vlook up to identify these deal ids to remove
and I know that I can sort them out but the goal is to create a filter
that can read the deal ID list (which will change) and remove the
records with those ids on the other tab.

suggestions??


--
barrfly

Excel User - Energy markets
------------------------------------------------------------------------
barrfly's Profile:
http://www.excelforum.com/member.php...fo&userid=4141
View this thread: http://www.excelforum.com/showthread...hreadid=472790



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
Long list of words to find with Filter englishtwit Excel Discussion (Misc queries) 2 July 29th 05 08:48 AM
Using advanced filter to search for criteria in a list Potatosalad2 Excel Discussion (Misc queries) 1 June 8th 05 03:08 AM
How to filter and list data based on different data. Defoes Right Boot Excel Worksheet Functions 3 April 13th 05 04:03 PM
Excel List range, filter arrows disappeared andrew Excel Discussion (Misc queries) 3 April 1st 05 11:30 PM
Excel Auto Filter: WHY'S SORT @ TOP OF LIST? WHEN I KEY TO "SHOW . Dan W Excel Worksheet Functions 0 December 1st 04 03:53 PM


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