LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Advanced Filter is unstable HELP

I am trying to create 4 lists of unique values that I can then use for a
sorting function on my sheet. The code below runs on opening of the sheet.
Typically on opening the wb the first time or if I manually involk the
advancedfilter function it works fine. This code even works until there is a
change to the source ranges (ie adding/deleting a record). Once that happens
the advanced filter fails to copy the data to the new location. Either all
three instances work OK or none do. It seems to execute OK, with no error,
but actually copies nothing.

'Determine height of dataset
Range("RPdb").Select
intRAdbH = Selection.Rows.Count
'Clear current sort lists
Range("RPdblist").Select
Selection.ClearContents
Range("RAdblist").Select
Selection.ClearContents
Range("RAmgrlist").Select
Selection.ClearContents
Range("RAspclist").Select
Selection.ClearContents

'Create new lists
Range("RPdb").Select
ActiveCell.Offset(intRAdbH + 5000, 0).Select
Selection.Name = "RPdbprime"
Range("RPdb").Select
Selection.Copy
Range("RPdbprime").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
Range("RPdbprime").Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RPdblist"
Selection.Sort Key1:=Range("RPdblist"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("RAdb").Select
ActiveCell.Offset(intRAdbH + 5000, 0).Select
Selection.Name = "RAdbprime"
Range("RAdbprime").Select
Range("RAdb").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"RAdbprime"), Unique:=True
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RAdblist"
Selection.Sort Key1:=Range("RAdblist"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("RAmgr").Select
ActiveCell.Offset(intRAdbH + 5000, 0).Select
Selection.Name = "RAmgrprime"
Range("RAmgr").Select
ActiveCell.Offset(intRAdbH + 1000, 0).Select
Selection.Name = "RAmgr1lbl"
Range("RAmgr").Select
Selection.Copy
Range("RAmgr1lbl").Select
Selection.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RAmgr1"
Range("RAmgrprime").Select
Range("RAmgr1").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"RAmgrprime"), Unique:=True
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RAmgrlist"
Selection.Sort Key1:=Range("RAmgrlist"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("RAmgr1").Select
Selection.ClearContents

Range("RAspc").Select
ActiveCell.Offset(intRAdbH + 5000, 0).Select
Selection.Name = "RAspcprime"
Range("RAspc").Select
ActiveCell.Offset(intRAdbH + 1000, 0).Select
Selection.Name = "RAspc1lbl"
Range("RAspc").Select
Selection.Copy
Range("RAspc1lbl").Select
Selection.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RAspc1"
Range("RAspcprime").Select
Range("RAspc1").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"RAspcprime"), Unique:=True
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "RAspclist"
Selection.Sort Key1:=Range("RAspclist"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("RAspc1").Select
Selection.ClearContents

Range("RAact").Select

 
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
Advanced Filter - filter rows < jaws4518 Excel Discussion (Misc queries) 3 November 1st 06 05:48 PM
Why won't advanced filter return filter results? jaws4518 Excel Worksheet Functions 5 September 12th 06 06:11 PM
How do I use advanced filter to filter for blank cells? Monique Excel Discussion (Misc queries) 2 March 21st 06 06:43 PM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM
advanced filter won't allow me to filter on bracketed text (-456.2 LucianoG Excel Discussion (Misc queries) 1 December 6th 04 08:38 PM


All times are GMT +1. The time now is 06:38 AM.

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"