+ Reply to Thread
Results 1 to 5 of 5

Using a closed MS Excel file in Macros

  1. #1
    Registered User
    Join Date
    08-02-2010
    Location
    Woking England
    MS-Off Ver
    Excel 2010
    Posts
    27

    Using a closed MS Excel file in Macros

    I am using Advance Filter to pull data from one file [File name:AVGUSAGE.xls Sheet Name:AVGUSAGE] to another file[FilterMacro.xls].

    I recorded the Marco for the advance filter. The code of that Macro is as follow:

    Please Login or Register  to view this content.
    The Macro runs fine as long as the sheet AVGUSAGE (from which I am pulling the data) is opened. When the sheet is closed the macro gives an error.

    I know I need to open that Sheet in Marco VB code. I am not at all familiar with VB but I somehow got to know how to open the file before program run and close it after it.

    After adding the open file code, my MARCO code looks like:

    Please Login or Register  to view this content.

    When I run my macro now it gives me an error:

    Run-time error ‘1004’: The exact range has a missing or illegal field name.

    Being a total stranger to VB, I have no idea where have I gone wrong.

    Do I have to declare workbook and worksheets and then use variables?

    Kindly help! My sheet can be downloaded from:

    http://rapidshare.com/files/410985318/AVGUSAGE.zip

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,239

    Re: Using a closed MS Excel file in Macros

    Which sheet and workbook are the criteria and destination ranges in?
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    08-02-2010
    Location
    Woking England
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Using a closed MS Excel file in Macros

    Quote Originally Posted by romperstomper View Post
    Which sheet and workbook are the criteria and destination ranges in?
    Thanks for the reply.

    Data to be pulled (List Range) is in File:AVGUSAGE.xls Sheet: AVGUSAGE

    The criteria and destination fields are in File: FilterMacro.xls. Sheet: Sheet1

    You can download the files from the link:

    http://rapidshare.com/files/410985318/AVGUSAGE.zip

    You will notice as long as both workbooks are open the macro will work. When you will close workbook AVGUSAGE, macro will stop working.

    Thanks

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,239

    Re: Using a closed MS Excel file in Macros

    I'm afraid I won't download files from there - you should attach them here instead.

    Try this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-02-2010
    Location
    Woking England
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Using a closed MS Excel file in Macros

    Its working perfect.

    Thanks a million

+ 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