+ Reply to Thread
Results 1 to 8 of 8

Creating a Filter based on variable data

  1. #1
    Registered User
    Join Date
    05-14-2018
    Location
    U.S.
    MS-Off Ver
    2010
    Posts
    3

    Creating a Filter based on variable data

    Hello, I'm working on an assignment to create a reaction time (RT) filter that is based on a given participant's reaction time data. So I will have a column for each participant where each row represents the reaction time of a given trial. I will want to create a cutoff for RTs that are slower than a user-defined point. The equation for this is slowestRT = meanRT + (StdDv * Mult) where "mult" is defined by the user and the rest is obtained from the participant's data. What I have is below. It doesn't generate an error, but nothing happens when I run it.

    Please Login or Register  to view this content.

    I'm sure I've done several things wrong here, but if anyone could get me on the right track it would be very much appreciated. For now I've set the mean and std. dev to set values, but once I've got the loop functioning I will figure out how to make them variable for each pariticipant.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by sfawzy; 05-14-2018 at 04:30 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a Filter based on variable data

    I am jumping on this before an Admin does. It will speed the process if you comply now.

    This also sound like something that might be accomplished with a named range.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html

    Also:


    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Code tags and sample workbook will speed the solution along!
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Creating a Filter based on variable data

    Maybe:

    Please Login or Register  to view this content.
    * I figured that you don't want to delete but just clear the contents?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    05-14-2018
    Location
    U.S.
    MS-Off Ver
    2010
    Posts
    3

    Re: Creating a Filter based on variable data

    Sorry for the bad form in my original post. I've updated now and included the attachment.

    xladept, What happens to the contents isn't actually that important, as long as the user would know not to use the content of that cell. So clearing them would be fine, or I would maybe have it read "reject" but I imagine that should be a straightforward adjustment.

    It looks like you've created another variable for the loops. Is that the major difference between yours and mine?

    The workbook I've attached is set up for multiple participants, but I don't know if I'll extend it to that, depending on how difficult it looks to be. As long as I can at least set up the function for a single subject's data I should be alright. So, ideally, the user pastes in a column of RT data and clicks "filter" button that holds the macro code, and it runs through each cell with the "slowestRT" equation, rejecting any cell that is greater than "slowestRT." It seems very basic, not sure why I'm not getting any output.

    Thanks,

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Creating a Filter based on variable data

    Variables are the major difference but using Row as a variable seems unwise that's why I tagged it with the underscore and For Row= 7 to Row seems self-defeating

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a Filter based on variable data

    I decided to be non-destructive and rather than overwrite the data, I overwrote a copy of the data so you can go back and try with different Multipliers for the same data or check the results.

    I also eliminated the need to prompt for the number of trials and the number of subjects. I "hard coded" up to 25 subjects (Columns B to Z) you don't have to fill these in. What the code does is get the last row in each column (eliminating the prompt for trails) and if the row is less than 7, it means there is no data for that subject and that column gets skipped.

    The consequences of this are, you can have as many trials as you want and you can have a different number of trials for each subject. Subjects do not have to be contiguous.

    When you click on Filter RT Data, you will be prompted for the multiplier and the program takes off from there.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-14-2018
    Location
    U.S.
    MS-Off Ver
    2010
    Posts
    3

    Re: Creating a Filter based on variable data

    I think that does it, dflak! Thank you so much!! I'm going to mark this as solved, but I might follow up with a question or two if I can't figure out how something works, if you don't mind. Thanks everyone for the feedback.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a Filter based on variable data

    Glad to be of service and I'll explain anything I can.

+ 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. [SOLVED] Creating an array of ones based on a variable
    By ChemistB in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 10-09-2015, 02:29 PM
  2. HALP! Creating a number of variables based on a variable.
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2014, 10:06 AM
  3. [SOLVED] Creating a Filter loop based on unique values in a column
    By Ragnarok_421 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2014, 05:34 AM
  4. Creating a custom filter based on a lookup table?
    By goldenglow90 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 03-16-2014, 05:44 PM
  5. Need help creating custom sheets based on auto filter results
    By trow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2012, 04:10 PM
  6. Sizing/creating an array based on a variable and a for loop
    By kyjocro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2011, 12:20 PM
  7. Advanced Filter based on variable.
    By goofy78270 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2007, 10:47 AM

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