Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default finding cells excluded by autofilter

Hi,

I am writing a macro to search for duplicates. I want to be able to apply
an auto filter and then for it search within those records. When I apply the
filter it still searches through the excluded cells. Is there anyway around
this.

My code is:

Dim SearchRange As Range
Dim EndRange As Range
Set EndRange = column.Find("")
Set SearchRange = Range(column.Cells(3), EndRange.Offset(1))

Selection.AutoFilter Field:=1, Criteria1:="Server"

Dim Book As Workbook
Dim OutputSheet As Worksheet
Set Book = Application.ActiveWorkbook
Book.Worksheets.Add After:=Book.Worksheets(1)
Set OutputSheet = Book.Worksheets(2)
OutputSheet.Name = "Test"
Dim OutputLine As Range
Set OutputLine = OutputSheet.Range("A1:D1")

For Each valuecell In SearchRange

If OutputSheet.Range("C:C").Find(valuecell.Value) Is Nothing _
And Not valuecell.Value = "" And Not valuecell.Value = "Unknown" _
And Not valuecell.Value = "Cable Management" _
And Not valuecell.Value = "UNKNOWN" Then
For Each searchcell In Range(valuecell.Offset(1), EndRange(-1))

If valuecell.Value = searchcell.Value Then

OutputLine.Cells(1).Value = valuecell.Address
OutputLine.Cells(2).Value = searchcell.Address
OutputLine.Cells(3).Value = valuecell.Value
OutputLine.Cells(4).Value = Sheets("Servers").Columns(1) _
.Cells(searchcell.Row).Value
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default finding cells excluded by autofilter

Possibly adding

set SearchRange = SearchRange.SpecialCells(xlVisible)

--
Regards,
Tom Ogilvy


"wbiskit" wrote:

Hi,

I am writing a macro to search for duplicates. I want to be able to apply
an auto filter and then for it search within those records. When I apply the
filter it still searches through the excluded cells. Is there anyway around
this.

My code is:

Dim SearchRange As Range
Dim EndRange As Range
Set EndRange = column.Find("")
Set SearchRange = Range(column.Cells(3), EndRange.Offset(1))

Selection.AutoFilter Field:=1, Criteria1:="Server"

Dim Book As Workbook
Dim OutputSheet As Worksheet
Set Book = Application.ActiveWorkbook
Book.Worksheets.Add After:=Book.Worksheets(1)
Set OutputSheet = Book.Worksheets(2)
OutputSheet.Name = "Test"
Dim OutputLine As Range
Set OutputLine = OutputSheet.Range("A1:D1")

For Each valuecell In SearchRange

If OutputSheet.Range("C:C").Find(valuecell.Value) Is Nothing _
And Not valuecell.Value = "" And Not valuecell.Value = "Unknown" _
And Not valuecell.Value = "Cable Management" _
And Not valuecell.Value = "UNKNOWN" Then
For Each searchcell In Range(valuecell.Offset(1), EndRange(-1))

If valuecell.Value = searchcell.Value Then

OutputLine.Cells(1).Value = valuecell.Address
OutputLine.Cells(2).Value = searchcell.Address
OutputLine.Cells(3).Value = valuecell.Value
OutputLine.Cells(4).Value = Sheets("Servers").Columns(1) _
.Cells(searchcell.Row).Value

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
How do I find data excluded from a list in excel? Nguyen92002 Excel Discussion (Misc queries) 3 January 15th 09 09:34 PM
Is there a function that allows me to list the names of excluded d Flutie99 Excel Worksheet Functions 1 June 1st 05 01:34 AM
HOW DO I EXCLUDED A FIGURE FROM A CONDITIONAL FORMAT???? [email protected] Excel Worksheet Functions 1 April 14th 05 10:14 PM
How to create a formula where high and low numbers are excluded [email protected] Excel Discussion (Misc queries) 2 March 6th 05 11:44 PM
Finding row count and filtered rows returned by Autofilter Joseph Uher Excel Programming 0 September 20th 03 08:49 PM


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