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: 13
Default Variable as argument in filter range

I'm trying to use the following to do filtering of a list of changing
length.
x = LastRow() ' this is a function that returns the last row in the
current list
Rng = "$A$2:$C$" & Trim(Str(x)) ' this concatenates that number to a
variable to
Range("A2").Select ' this sets the selection at the top of the list.

' from what I can determine the following to lines should be identical. BUT
the one with the variable causes an error.
' while the second line works fine.

Range(Rng).AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range("I2:I3"), CopyToRange:=Range("M1:O1"), Unique:=False

Range("A1:C119").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range("I2:I3"), CopyToRange:=Range("M1:O1"), Unique:=False

I've tried creating Rng to equal "$A$2:$C$119" and tried
Range(Cells(2,1),Cells(x,3)) all with the same error: "Run-time error 1004.
The extract range has a missing or illegal field name."

Any suggestions would be appreciated.
Thanks
Bert


 
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
Average: 2nd argument as a variable in another cell av(c6:c(a3)) Tony the Tiger Excel Discussion (Misc queries) 2 May 5th 08 12:39 AM
Range as argument in function Asif[_3_] Excel Programming 3 December 6th 03 01:38 PM
type variable as argument of a sub Koos Excel Programming 1 October 23rd 03 11:41 AM
Passing range as argument Jan Kronsell[_2_] Excel Programming 3 September 3rd 03 12:31 PM
passing a variable as an argument to a function Drew[_6_] Excel Programming 3 July 25th 03 08:51 PM


All times are GMT +1. The time now is 09:18 AM.

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"