Wrox Programmer Forums
|
BOOK: Excel 2000/2002 VBA Programmer's Reference
This is the forum to discuss the Wrox book Excel 2000 VBA: Programmers Reference by John Green, Stephen Bullen, Felipe Martins, Brian Johnson; ISBN: 9780764544019
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel 2000/2002 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2010, 04:45 PM
Registered User
 
Join Date: Nov 2004
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Advanced Autofilter not working

I have a form with comboboxes and textboxes that collect the user's search criteria. the function WriteValues2CritRng then assigns those values to a range defined as "rgCriteria", which has as its first line the row headers. My rgExtract also has row headers as its first line.

I copied the code from page 173 of the book (adding the line for the function WriteValues2CritRng:

Private Sub cmdSearch_Click()
Dim rgDB As Range
Dim rgCriteria As Range
Dim rgExtract As Range

Set rgDB = Range("Database")
Set rgCriteria = Range("Criteria")
Set rgExtract = Range("Extract")

WriteValues2CritRng

rgDB.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=rgCriteria, _
CopyToRange:=rgExtract
End Sub

The code runs fine, no errors or anything, but no rows are extracted. I don't have a clue as to how to go about debugging this. Any ideas? Thanks.

--elizabeth
 
Old April 1st, 2010, 04:47 PM
Registered User
 
Join Date: Nov 2004
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Oh, I should have mentioned that my data (rgDB) is on another worksheet in the workbook. Also, I have used the simple Autofilter to copy and delete rows to other spreadsheets with no problem.
--e
 
Old October 27th, 2010, 11:46 AM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 171
Thanks: 0
Thanked 14 Times in 14 Posts
Default

it sounds like the criteria range isn't getting the right criteria, it has some condition that none of the records meet, like a date range into which none of them fall. Do it manually until you get the right result and then change your code accordingly.





Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoFilter SteveB BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 July 1st, 2009 06:52 PM
Advanced filter not working Umasriram2 Excel VBA 1 February 4th, 2009 06:03 PM
Remove Autofilter yogeshyl Excel VBA 4 June 11th, 2007 06:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.