+ Reply to Thread
Results 1 to 6 of 6

Macro to extract records from a list

  1. #1
    Registered User
    Join Date
    10-16-2007
    Posts
    24

    Macro to extract records from a list

    Hi,

    Can anyone tell me why I can't run this macro? Please tell me what the error is. Thanks
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    The problem occurs when trying to AutoFilter. I'm not sure what it is you're trying to do with the AutoFilter, but if you're trying to make a copy of the data and drop it into a different WorkSheet this is not allowed by Excel. You can first drop it in the same Worksheet then do a cut/copy and paste into a different worksheet.

  3. #3
    Registered User
    Join Date
    10-16-2007
    Posts
    24
    Hey,

    I am not too sure but I did find this on the website. http://www.meadinkent.co.uk/xlfilter.htm

    It says,
    "A macro can be used to automate the filtering process - identifying a List range, pre-programmed with the Criteria and the Copy to ranges. The results can be on a different worksheet than the original data."

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Actually, this is correct. I didn't realize this could be done, but I see how now. I believe you have to have the worksheet you are copying TO active in order to do this though. Also, if you are copying the data from a different worksheet make sure the autofilter is aware of this (i.e. range("A1:E5") is not the same thing as sheets("Sheet1").range("A1:E5") when the activesheet is "Sheet2").
    So, run the macro with "Data" sheet active, then add this line:
    Please Login or Register  to view this content.
    right before the autofilter. Also, you will have to make sure you are pasting to a completely blank area. So even the headers: grade, surname, etc. cannot exist where the autofilter is to be copying to.

  5. #5
    Registered User
    Join Date
    10-16-2007
    Posts
    24
    hmm., do you think you can change it in the current file that I sent you. I'm not good with VB so i will need an example file to see. Thanks

  6. #6
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    See attached. Here is the code:
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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