+ Reply to Thread
Results 1 to 16 of 16

How to step among entries of autofilter via VBA code?

  1. #1
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    How to step among entries of autofilter via VBA code?

    Dear All,

    I've faced with a problem while I try to create a sub - autofilter A column and select the...

    - first entry (but not as a unique item, as data may changes weekly)
    once 1st item filtered - I'd do some function: sum weekly results, and keep only one row with the filtered item (paste special/delete rows)

    - than step on next entry and do the same as before

    - take these steps till the end of autofilter list, than remove autofilter.

    .. with this action, I'd get the sum value of my weekly forcast on each incividual items.

    Would you pls. help to solve this problem, as I've no clue how should I do it.. : (

    Thanks a lot in advance!
    Adam

    ps:

    I've started as:

    ActiveSheet.Range("$A$2:$BN$400").AutoFilter Field:=1, Criteria1:= _
    "17963-E050LF"

    but critera shoul be like .. 1st entry ... 2nd entry ... last entry .. session end .. ?!
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by ahenin; 01-25-2014 at 11:42 AM. Reason: attachment

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to step among entries of autofilter via VBA code?

    I think I know what you want, but not entirely sure... However, perhaps if you sort on the item IDs and use the SubTotal function (Data Tab), you might get the results you want.

  3. #3
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Thanks Cytop, I'll try!
    Last edited by ahenin; 01-25-2014 at 10:40 AM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    Hi ahenin

    Pictures are of little value.

    Please attach a sample file that represents what you have. The structure of your attachment should be the same structure as your actual data. Any proprietary information should be changed.

    Include in the attachment any code you're currently using (whether it works or not) and an "After" of what you wish the output to be.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Hi Cytop,

    It wasn't worked ... as Subtotal showed the total value of a row, but I must keep weekly data instead of sum at the end...
    ..if only one line under an item result may ok, if a filter brings 3 rows for example I must sum the columns separatelly, keep the sumarized row, and remove the others... so I'd create a code in VBA for this process.

  6. #6
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Thanks in advance Jaslake!
    Adam
    Attached Files Attached Files

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    Hi ahenin

    This Code is in the attached and appears to do as you require...CTRL + z will fire the Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Thanks a lot for your effort Jaslake!

    However you've solved this problem in another way and your code is brilliant...!
    ..I must try to understand first to be able to use for other methods as well..


    Would you pls. take a look on the file just enclosed?
    As I don't see real difference between this and the file I sent before, but with this your code is doesn't work... : (

    Thanks again!
    Adam

    ps: do you know a code otherwise to step an entry in autofilter?
    Attached Files Attached Files

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    Hi ahenin

    The structure of your Workbooks are different. Code is based on that Structure.

    I'll get back to you tomorrow. In the meantime...notice the difference?

  10. #10
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Hi jaslake,

    ohh.. you or I may removed first row..
    Gosh it's working now!!!

    Thanks a lot for all your help!
    Adam

  11. #11
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Hi Jaslake,

    For some reason the code you made do not count after the 20th row.
    Furthermore I just left sheet 'raw data' as a reference, but now seems both sheet must be the same?!

    I know my idea would be less sofisticated, but I guess the - autofilter/next item selection would be more accurate..
    Do you know the code of this?

    Thanks
    Adam
    Attached Files Attached Files

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    Hi ahenin

    If the solution you described in your PM works for you go with it.

    Regarding this
    the code you made do not count after the 20th row
    I simply got lazy...the Code in the attached remedies this.

    Regarding this
    I just left sheet 'raw data' as a reference, but now seems both sheet must be the same?!
    You can run the Code on either Worksheet as long as the Structures are the same...merely change this line of Code
    Please Login or Register  to view this content.
    Here's the revised Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    That really a great help jaslake!
    Thanks!
    Adam

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    You're welcome...glad I could help. Thanks for the Rep.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to step among entries of autofilter via VBA code?

    Hi Adam

    Here is the Commented Code...anything you don't quite understand...let me know.
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    01-25-2014
    Location
    Hungary
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to step among entries of autofilter via VBA code?

    Hi jaslake,

    It's really great!
    I learned a lot from your code!

    Adam

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to randomly choose sample rows after using Autofilter??
    By Saarang84 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2009, 03:43 AM
  2. [SOLVED] can i get excel to choose every 10th entry in a spreadsheet
    By Peo Sjoblom in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  3. [SOLVED] can i get excel to choose every 10th entry in a spreadsheet
    By whaler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  4. can i get excel to choose every 10th entry in a spreadsheet
    By whaler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  5. can i get excel to choose every 10th entry in a spreadsheet
    By whaler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

Tags for this Thread

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