PC Review


Reply
Thread Tools Rate Thread

Advanced filter with naming range

 
 
Catherine
Guest
Posts: n/a
 
      16th Jul 2008
Hi,

I need to copy all the data from SheetB with ENV_342 criteria to SheetA. I
am using the advanced filter. In this code I am using the range A5:B911, but
I need to replace this by FILTER naming range. If I just replace the text
“A5:B911” with FILTER I received the execute error message 1004. Do anyone
have a solution?

I am using Excel 2003.

This is my actual code

Sheets("Sheet B").Range("A5:B911").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A1:A2"), CopyToRange:=Range("A3"), Unique:=False

Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ENV_342", RefersTo:=Selection


Thanks
Catherine

 
Reply With Quote
 
 
 
 
NoodNutt
Guest
Posts: n/a
 
      19th Jul 2008
G'day Catherine

You may find this link helpful

http://www.rondebruin.nl/copy2.htm

here is a copy of my code that I modified to suite my purposes based on
Ron's Code.

Sub Split_Data()

Dim SourceSheet As Worksheet
Dim DestinationSheet As Worksheet
Dim rng As Range
Dim rng2 As Range

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set SourceSheet = Sheets("Data")
Set rng = SourceSheet.Range("A8:M" & Rows.Count)
Set DestinationSheet = Sheets("NSW")

SourceSheet.AutoFilterMode = False
rng.AutoFilter Field:=1, Criteria1:="=SYD"

SourceSheet.AutoFilter.Range.Copy
With DestinationSheet.Range("A5")
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
.Select
End With
End Sub

This peice of code copies only rows that match "Syd" in the first column and
copies it to my new sheet NSW, you can also create a new sheet.

HTH
Mark.


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      20th Jul 2008
> http://www.rondebruin.nl/copy2.htm

I think Mark wanted to post this link
http://www.rondebruin.nl/copy5.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"NoodNutt" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> G'day Catherine
>
> You may find this link helpful
>
> http://www.rondebruin.nl/copy2.htm
>
> here is a copy of my code that I modified to suite my purposes based on
> Ron's Code.
>
> Sub Split_Data()
>
> Dim SourceSheet As Worksheet
> Dim DestinationSheet As Worksheet
> Dim rng As Range
> Dim rng2 As Range
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> Set SourceSheet = Sheets("Data")
> Set rng = SourceSheet.Range("A8:M" & Rows.Count)
> Set DestinationSheet = Sheets("NSW")
>
> SourceSheet.AutoFilterMode = False
> rng.AutoFilter Field:=1, Criteria1:="=SYD"
>
> SourceSheet.AutoFilter.Range.Copy
> With DestinationSheet.Range("A5")
> .PasteSpecial xlPasteValues
> Application.CutCopyMode = False
> .Select
> End With
> End Sub
>
> This peice of code copies only rows that match "Syd" in the first column and
> copies it to my new sheet NSW, you can also create a new sheet.
>
> HTH
> Mark.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced Filter using a range name as the criteria Joe Microsoft Excel Worksheet Functions 1 27th Dec 2008 06:23 PM
advanced filter a range =?Utf-8?B?SWwgUHJpbmNpcGU=?= Microsoft Excel Worksheet Functions 2 1st Aug 2005 03:27 PM
Advanced Filter Range Selection in VB Hulk Microsoft Excel Programming 0 3rd Oct 2004 02:39 AM
Advanced Filter Range Selection in VB Hulk Microsoft Excel Programming 1 3rd Oct 2004 02:26 AM
copy results of advanced filter to a dynamic range - if only want certain records from the results - filter used to narrow down selection Cheryl Microsoft Excel Discussion 1 20th May 2004 02:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:22 AM.