MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Scope and Global Range error


Posted by Melanie Swarner on November 08, 2001 6:27 AM

I have recorded the following macro.

Public Sub ApplyAdvancedFilter()
Range("Database").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range _
("Criteria"), CopyToRange:=Range("Extract"), Unique:=True
End Sub

I had it in my "personal.xls" and attached it to a button on my toolbar. It worked fine in any worksheet with named ranges Database, Criteria and Extract.

Now, I have another subprocedure that calls it. It didn't want to work in personal. It said it was not defined so I tried moving it into a module in my application. Then it said global object range not defined.

Any ideas? Is there some way to make a subprocedure global or am I just missing something?

Thanks!


Posted by Melanie Swarner on November 08, 2001 6:54 AM

Nevermind.....

I figured it out. I have to select the sheet I defined the names in first. Then it works fine no matter where it is (in the app or in personal.xls)

Hope this helps someone else!