Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 February 4th, 2009, 12:50 PM
Authorized User
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Advanced filter not working

I've a file with data in "Unprocessed" tab. The objective is to filter “Unprocessed” tab based on the criteria set out in “criteria” sheet and create separate sheets for each criterion, copy paste the filtered data from the “Unprocessed” tab. The criteria is set out from Row 2 and in Row 1, I've mentioned the Criteria name which would also be the new sheet name. Though the macro runs, it pulls out correct data only for the second criterion and not for other. here is the code....Could someone help pl!

Dim rng1 As Range
Dim crit1 As Range
Dim shname As String
Dim countrange As Range
Dim i As Integer
Dim c As Integer
Dim Newsheet As Worksheet
Sheets("criteria").Select
Set countrange = Sheets("criteria").Range("A1", Sheets("criteria").Range("A1").End(xlToRight))
c = countrange.Columns.Count
If c = 256 Then c = 1
For i = 1 To c
Set Newsheet = Sheets.Add(Type:=xlWorksheet) 'Add new worksheet
Sheets("criteria").Select
Set crit1 = Sheets("criteria").Range(Cells(2, i), Cells(2, i).End(xlDown))
Sheets("Unprocessed").Select
Cells.Select
Set rng1 = Sheets("Unprocessed").Range("A1", Sheets("Unprocessed").Range("A1").End(xlDown).End( xlToRight))
rng1.AdvancedFilter xlFilterInPlace, crit1, , False
Selection.Copy
Newsheet.Paste
Application.CutCopyMode = False
'Sheets("criteria").Select
shname = Sheets("criteria").Cells(1, i).Text
Newsheet.name = shname
'Sheets("Unprocessed").ShowAllData
Next i
'Sheets("Unprocessed").ShowAllData
'ActiveWorkbook.Save
End Sub
 
Old February 4th, 2009, 06:03 PM
Authorized User
 
Join Date: Nov 2007
Posts: 48
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Umasriram2,

This may help.

NorieDistributeRowshttp://www.mrexcel.com/forum/showthread.php?t=315083


Have a great day,
Stan
__________________
stanleydgromjr

Windows 8.1, Excel 2007.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter not working grrrrr chris1012 Visual Studio 2008 0 December 17th, 2008 07:19 PM
Where are the Advanced button? micror BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 7th, 2006 07:28 AM
Macro/Date/Advanced Filter alexyss15 Excel VBA 1 March 30th, 2006 01:06 PM
Automatically Applying Advanced Filter / Sort bridog39 Access 4 November 24th, 2005 04:18 PM
advanced listobox! Please Help Varg_88 Javascript 4 September 29th, 2004 01:49 AM





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