Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
The statement
Sheets("Cash Bks").Range("CashBookData").AdvancedFilter _ Action:=xlFilterCopy, _ CriteriaRange:=Range("DieselCriteria"), _ CopyToRange:=Range("DieselOutputRange"), Unique:=False works but it gives the error "Method 'Range' of object '_Worksheet' failed" without the Sheets("Cash Bks") part as in Range("CashBookData").AdvancedFilter _ Action:=xlFilterCopy, _ CriteriaRange:=Range("DieselCriteria"), _ CopyToRange:=Range("DieselOutputRange"), Unique:=False The named range "CashbookData" refers to a range in another worksheet. I would like to exclude the Sheets("Cash Bks") part from the VBA statement as I want to make this sheet more adaptable ie not have to change the VBA code if the workbook that CashBookData resides in changes. Is there a way to work around this? Thanks in advance Laurence Lombard |
#2
![]() |
|||
|
|||
![]()
If it's a workbook level name, you could do the following:
Dim rngList As Range Set rngList = ActiveWorkbook.Names("CashBookData").RefersToRange rngList.AdvancedFilter Action:=xlFilterCopy, _ CriteriaRange:=Range("DieselCriteria"), _ CopyToRange:=Range("DieselOutputRange"), Unique:=False Laurence Lombard wrote: The statement Sheets("Cash Bks").Range("CashBookData").AdvancedFilter _ Action:=xlFilterCopy, _ CriteriaRange:=Range("DieselCriteria"), _ CopyToRange:=Range("DieselOutputRange"), Unique:=False works but it gives the error "Method 'Range' of object '_Worksheet' failed" without the Sheets("Cash Bks") part as in Range("CashBookData").AdvancedFilter _ Action:=xlFilterCopy, _ CriteriaRange:=Range("DieselCriteria"), _ CopyToRange:=Range("DieselOutputRange"), Unique:=False The named range "CashbookData" refers to a range in another worksheet. I would like to exclude the Sheets("Cash Bks") part from the VBA statement as I want to make this sheet more adaptable ie not have to change the VBA code if the workbook that CashBookData resides in changes. Is there a way to work around this? Thanks in advance Laurence Lombard -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Like 123, allow named ranges, and print named ranges | Excel Discussion (Misc queries) | |||
Macro (Print) - Calling Named Ranges | Excel Discussion (Misc queries) | |||
Named Ranges | Excel Discussion (Misc queries) | |||
Poor Workbook Performance due to Named Ranges | Excel Discussion (Misc queries) | |||
Named dynamic ranges, copied worksheets and graph source data | Charts and Charting in Excel |