+ Reply to Thread
Results 1 to 13 of 13

Thread: Which would you prefer?

  1. #1
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,431

    Which would you prefer?

    Hey All,

    While i was replying to so many VBA related threads, a question struck me and i couldnt decide which was better among the two. I thought of putting forth this question to all of you so you can provide your opinion.

    If you receive a question wherein the user would like to transfer the contents from one master sheet to several other sheets, split by for eg. month / date. Would you choose to use the autofilter method (get the list of unique dates and then filter by each date and copy to the respective tab) or would you go row by row through a loop and then copy the row to the appropriate tab?

    While running the code, which is more efficient and faster? Is it the autofilter or the row by row method?

    Need your inputs.

    Thanks everyone....have a nice day !!!
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  2. #2
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,160

    Re: Which would you prefer?

    Hi arlu1201

    The filter would be faster .. But if you are writing the code its your call . No right or wrongs just is.

    all loops are slow
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

  3. #3
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,256

    Re: Which would you prefer?

    I'd choose the filter approach, though I think would be an Advanced filter rather than Autofilter.

    Regards, TMS

  4. #4
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Which would you prefer?

    Autofilter is more efficient to my knowledge. The only problem you can have is if the filtered data results in a range reference that is too complex to copy.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  5. #5
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Which would you prefer?

    I couldnt decide which was better among the two
    There are probably more methods to get the same results:

    - a databasequery
    - putting the data into an array, filter that in memory and writing the results to separate worksheets

    If you post a sample file we all can do some testing and compare the results.



  6. #6
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,252

    Re: Which would you prefer?

    Quote Originally Posted by snb View Post
    There are probably more methods to get the same results:

    - a databasequery
    - putting the data into an array, filter that in memory and writing the results to separate worksheets.
    Or a filtered disconnected recordset?

  7. #7
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,431

    Re: Which would you prefer?

    What is a filtered disconnected recordset?
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Which would you prefer?

    Have a look over here.



  9. #9
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,252

    Re: Which would you prefer?

    or better, look here

  10. #10
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Which would you prefer?

    I've come across using disconnected recordsets before in a VBA book I skimmed through and they seem like they should be really useful, unfortunately I've never come a situation where they would actually be useful :s

    Plus I don't know of a way of filling them without looping (or memory leaks) which has always put me off.

    Maybe this is their calling - lots of filtering and finding on a dataset! They do look as though they would be much faster than filtering in Excel
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  11. #11
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: Which would you prefer?

    I'd suspect arrays would be faster than filters.
    Good luck.

  12. #12
    Forum Guru Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    MS Excel 2010
    Posts
    2,252

    Re: Which would you prefer?

    Quote Originally Posted by OnErrorGoto0 View Post
    I'd suspect arrays would be faster than filters.
    Is that based upon any evidence or your gut feeling?

  13. #13
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: Which would you prefer?

    A little of both. I have seen similar questions where arrays have proven faster especially with large datasets. Here I think you would need to preprocess the data to get a list of dates to filter by and if you're going to iterate them anyway, I suspect it would be faster to do the work as you go (not copying row by row obviously!).
    However, unless speed were critical I would probably actually use the autofilter method for simplicity.
    Good luck.

+ 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.2.0