+ Reply to Thread
Results 1 to 12 of 12

filtering problem, wrong rows removed

  1. #1
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    filtering problem, wrong rows removed

    Hi All,

    I have a module that imports data from a text file (120000 rows), filters and removes some unneeded (85000)rows and then puts the data in a designated workbook.
    Problem: when filtering by some criteria it for some reason removes a row off the final file for each criteria. I have a total of 23 filtering criteria. I have attached a file for exemplification. You can run the module and import the file, it will be without first 23 rows, even if non of the deleted rows contained the filter criteria.
    example.txt
    Please Login or Register  to view this content.
    Please look into the code and help me figure out what is wrong with it.
    Any ideas appreciated.
    Last edited by rinser; 12-17-2009 at 06:25 AM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: VBA, filtering problem, wrong rows removed, sthng is wrong with the code

    Taking just this bit of code
    Please Login or Register  to view this content.
    So what you code does is: it removes all the rows that meat the 23 criteria (exept the last row) including the column header. I think deleting the header is not OK. maybe this should be offset(1,0) instead of offset(0,0)
    Last edited by rwgrietveld; 12-12-2009 at 10:00 AM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    Re: VBA, filtering problem, wrong rows removed, sthng is wrong with the code

    Hi rwgrietveld,

    I tried the offset (1,0) but no luck so far. I don't know if there is the problem with the header as the data begins at row 1.

    Cheers.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA, filtering problem, wrong rows removed, sthng is wrong with the code

    AutoFilter assumes that you have a header row. You need to add one.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    re: filtering problem, wrong rows removed

    I am adding a header row but it's not working so far. Probably I am adding it in the wrong place in the code sequence.
    Last edited by rinser; 12-15-2009 at 04:45 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: filtering problem, wrong rows removed

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Do not use unnecessary words like VBA in your thread titles.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    Re: filtering problem, wrong rows removed

    Thank you. Noted.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: filtering problem, wrong rows removed

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  9. #9
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    Re: filtering problem, wrong rows removed

    Hi guys,
    Sorry if I am extending the topic, thought it would be quicker this way since the code is already present in my first post.

    Update: my modules are working quite fine after some fiddling except for one thing: given the number of rows (>105,000) it imports the entries on two worksheets. After the filtering is done the first row from the second worksheet, mainly row number 65537 is kept even if it shouldn't be according to filtering criteria. I think it is because of the offset(1,0) command, it does what I want on the first worksheet, but on the second it keeps the first row out of filter and it stays in the final table of results (about 20,000). Please let me know if you understand my explanation so far and what you think. Unfortunately I cannot attach a file as it would be nightmare to produce at least 67,000 rows of dummy data.
    Cheers.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: filtering problem, wrong rows removed

    First, you have to work within AutoFilter's limitations; see http://support.microsoft.com/kb/295971 and http://excel.tips.net/Pages/T002403_...own_Limit.html. You may need to break the data up into sections much smaller than 64K rows per sheet.

    Second, every sheet needs a header row.

  11. #11
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    Re: filtering problem, wrong rows removed

    I seem to not be affected by the 1000 limitation.

    Does anyone know how can I insert in my code the header row for the second worksheet?

    Cheers.
    Last edited by rinser; 12-15-2009 at 04:46 PM.

  12. #12
    Forum Contributor rinser's Avatar
    Join Date
    02-27-2009
    Location
    Bucharest
    MS-Off Ver
    MS Office 2013
    Posts
    103

    Re: filtering problem, wrong rows removed

    Hi guys,

    After some testing and checking the solution proposed by rwgrietveld worked. It seems it was the wrong offsetting that was the cause.

    Thank you all for the help and support!

+ 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