+ Reply to Thread
Results 1 to 3 of 3

VBA Autofilter in another workbook

  1. #1
    Registered User
    Join Date
    03-18-2009
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    12

    Smile VBA Autofilter in another workbook

    I'm trying solve a problem I have, but I can't find a solution anywhere.

    I've got two workbooks.
    One with my macros (workbook 1), and one that is generated each week, with different file names (workbook 2).

    I've got a button in workbook 1 that's supposed to:
    1. Let me select another file (workbook 2).
    2. Open it, select the range "A2:W2" in it and create a autofilter.
    3. Filter the 17th column to match the cell "Z19" in workbook 1.

    I've tried numerous of different solutions from people with similar problems,
    but I can't get it to work.

    Here's what I got:
    Please Login or Register  to view this content.
    Sheet 5 in workbook 2 is named "Job list". That stays the same
    even when the new file is generated. If that helps.

    It opens a dialogue box, that let's me select a file, and opens it.
    So far so good.
    But the autofilter part is applied to workbook 1 instead of 2.

    I know that the part with ws doesn't do anything. That is just left
    from one of my alternative attemps.

    I've tried with Windows. and Workbook. Activate, but with the same
    result.
    Last edited by stuntmannen; 09-27-2010 at 01:53 PM. Reason: Solved!

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA Autofilter in another workbook

    Try this. You didn't have any workbook/sheet references so macro ran on whatever was active at the time.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-18-2009
    Location
    Gothenburg
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: VBA Autofilter in another workbook

    Aaah! Works perfectly!

    Thank you so much! Tomorrow I can spend my time at work with actual work instead!

    Thanks again! Love this site!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1