+ Reply to Thread
Results 1 to 7 of 7

Code the saves filter info to reapply after running other code

  1. #1
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Code the saves filter info to reapply after running other code

    Is this possible? Can a macro remember current filter settings to reapply them after running some other macro?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Code the saves filter info to reapply after running other code

    Hey Wedge120,

    This is a tough question. There is .Refresh in VBA to reapply a filter and sort on a pivot table. There are Advanced Filter commands that can filter and sort data. There are Global variables that can "remember" values between running other subs. But I'm not sure you can tell VBA to do that thing that was done a while ago.

    I have seen code to UNDO what a macro has done, but it had to remember all kinds of stuff. So much so it wasn't worth the effort. See http://www.j-walk.com/ss/excel/tips/tip23.htm

    How about giving us an example of exactly what you are thinking and maybe it would help.

    One of the smart guru's will probably have a quick answer that I'm not aware of.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Code the saves filter info to reapply after running other code

    In this workbook, I choose which parts I need (rows), and I place the number needed in column "R". After I enter the number needed in this column, I run a "sheetstats" macro that looks at the parts I have chosen and provides totals and other info about the parts chosen.

    Before placing these quantities in column "R", I use the autofilter to gradually pick and choose parts based on the various critieria. In order to run my "sheetstats" macro, however, the filters are cleared as this macro releases them in order to make calculations.

    I was wondering if there were a way to run the "sheetstats", but also see the filters that were used to make my choices.

    I guess and alternative way to achieve this would be to write the "sheetstats" macro in a way that doesn't require the release of the filters, but I really don't know how.
    Attached Files Attached Files
    Last edited by Wedge120; 08-25-2011 at 02:19 PM.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Code the saves filter info to reapply after running other code

    Hi,

    There is no "sheetstats" macro included in your sample file.

    I'm starting to understand your problem. What if you had a helper column where you put an X in a row of the parts you have chosen. Then you could filter on this column being an x or not. Do your calculations and the x would still be there. You could create a macro to clear all the x's in that column to start over.

    See the attached where I have code to double click a column to put or erase an x in it.

    We need to see the sheetstats macro to make a determination on it.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Code the saves filter info to reapply after running other code

    Please download the file again. What a newbie mistake I made

    The SheetStats is still a work in progress. I need to make each calculation its on sub, and call them in the order they are needed. So please ignore the sloppy coding; I realize it makes it hard to read. That being said, you can place numbers in column R and run SheetStats.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Code the saves filter info to reapply after running other code

    Hi Wedge120,

    You have about 500 lines of code that I'm falling asleep reading. Can you explain in words what you are trying to do? How do you pick the rows? What is the number in Column R for? Aren't you simply doing an advanced filter to another section of the worksheet and totals from it?

    Have you looked at advanced filters instead of Auto Filter to do this?
    http://www.contextures.com/xladvfilter01.html
    http://www.excelfunctions.net/ExcelAdvancedFilter.html

  7. #7
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Code the saves filter info to reapply after running other code

    Oh lord I didn't intend for you to examine that code ! Sorry! I just thought you would run the macro to see what it does.

    I will look at the links you provided. I am not sure if what I am doing is an advanced filter or not.

    I am heading home from work, but will respond back when I get home, hopefully in a much more lucid fashion. I do appreciate your time.

+ 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