Ask Experts Questions for FREE Help !
Ask
    nikeshtnt's Avatar
    nikeshtnt Posts: 52, Reputation: 1
    Junior Member
     
    #1

    Mar 2, 2009, 06:24 AM
    Excel Filter Macro needed
    I have a list and want to filter it with reference to a cell. e.g. list is ranging from Row 5 to 2000, I want to assigne Cell A4 as reference to filter the data. When something is entered in A4 then it should check that A5 to A2000 has that data or not if yes then filter or else don't execute and let other formula work based on A4.

    I have attached the sample list. Here I have entered 1003041 in A4 and want to get the below filtered list automaticaly.
    Attached Files
  1. File Type: xls Query.xls (81.0 KB, 903 views)
  2. StaticFX's Avatar
    StaticFX Posts: 943, Reputation: 74
    Senior Member
     
    #2

    Mar 2, 2009, 06:51 AM

    open your sheet...
    Hit ALT+F11 to get to the code window
    dbl click the SHEET1 to open that code window

    paste this in:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Address = Range("b4").Address Then
            Selection.AutoFilter Field:=1, Criteria1:=Range("A4").Value
        End If
    End Sub
    now enter a value and hit tab (or click in B4) entering B4 will activate it
    nikeshtnt's Avatar
    nikeshtnt Posts: 52, Reputation: 1
    Junior Member
     
    #3

    Mar 2, 2009, 07:38 AM
    Quote Originally Posted by StaticFX View Post
    open your sheet....
    Hit ALT+F11 to get to the code window
    dbl click the the SHEET1 to open that code window

    paste this in:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Address = Range("b4").Address Then
            Selection.AutoFilter Field:=1, Criteria1:=Range("A4").Value
        End If
    End Sub
    now enter a value and hit tab (or click in B4) entering B4 will activate it
    Great buddy... it works like bullet..

    But I want to go one step furter.

    Now I have two sheets and want to get this filtered data in other sheet. I have attached again other sheet in this sheet I want to enter data in sheet P in cell C7 and want to get the filtered data should be copied in Sheet P (as shown) from sheet Detail. Please note that Sheet Detail would be hided for user of this file.

    As shown in sheet I have entered 1002707 in C7 of Sheet P and want to get the data from Sheet Detail to be pasted in Sheet P from G24 to end as rquired.
    Attached Files
  3. File Type: xls Payment.xls (96.0 KB, 521 views)
  4. JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #4

    Mar 2, 2009, 04:07 PM

    Here's a version that does not require a macro. It is using an array to watch the Detail sheet and draw the list in realtime. If you change the employee code, the list will reorient automatically.

    This is accomplished with array formulas and a helper cell on the Detail sheet that tells the chart on "P" how many matches to bring over.

    The arrays work great, but if you had 1000s of cells with arrays in them, each one evaluating 1000s of rows of data on the Detail sheet, your sheet might start to slow down. If that's not a problem for you, then this is ready to use, no macro needed.

    If you decide you don't like array formulas, but don't mind adding an entire helper "column" on the detail sheet, I could make this even more dynamic and remove the arrays on the P sheet. It still wouldn't require a macro, but the helper column would allow us to create a unique "index" and with that we can use simple INDEX/MATCH formulas to create the chart on the P sheet.

    INDEX/MATCH formulas are so fast you could have 10s of thousands of them going on with no noticeable slowing of the sheet.

    Let me know if you want to see the version without the arrays.
    Attached Files
  5. File Type: xls Payment.xls (121.5 KB, 678 views)
  6. nikeshtnt's Avatar
    nikeshtnt Posts: 52, Reputation: 1
    Junior Member
     
    #5

    Mar 2, 2009, 11:50 PM
    Quote Originally Posted by JBeaucaire View Post
    Here's a version that does not require a macro. It is using an array to watch the Detail sheet and draw the list in realtime. If you change the employee code, the list will reorient automatically.

    This is accomplished with array formulas and a helper cell on the Detail sheet that tells the chart on "P" how many matches to bring over.

    The arrays work great, but if you had 1000s of cells with arrays in them, each one evaluating 1000s of rows of data on the Detail sheet, your sheet might start to slow down. If that's not a problem for you, then this is ready to use, no macro needed.

    If you decide you don't like array formulas, but don't mind adding an entire helper "column" on the detail sheet, I could make this even more dynamic and remove the arrays on the P sheet. It still wouldn't require a macro, but the helper column would allow us to create a unique "index" and with that we can use simple INDEX/MATCH formulas to create the chart on the P sheet.

    INDEX/MATCH formulas are so fast you could have 10s of thousands of them going on with no noticeable slowing of the sheet.

    Let me know if you want to see the version without the arrays.
    Hi JB.. good to here you again..

    I would go for without arrays because we work on systems which are very old & slow.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #6

    Mar 3, 2009, 02:13 AM

    As I said, the arrays are fine (even on older systems) as long as you limit how many columns are trying to use them.

    Anyway, here's the same sheet again with a dynamic chart on sheet P that uses no arrays at all. All we did was add an "index" column in the Detail. Whatever employee code you select will cause unique IDs to appear for the matching rows in the index, and a simple INDEX/MATCH formula brings them over starting at 1 and up to the MAX index value.
    Attached Files
  7. File Type: xls Payment.xls (142.5 KB, 603 views)
  8. nikeshtnt's Avatar
    nikeshtnt Posts: 52, Reputation: 1
    Junior Member
     
    #7

    Mar 4, 2009, 12:05 AM
    Quote Originally Posted by JBeaucaire View Post
    As I said, the arrays are fine (even on older systems) as long as you limit how many columns are trying to use them.

    Anyway, here's the same sheet again with a dynamic chart on sheet P that uses no arrays at all. All we did was add an "index" column in the Detail. Whatever employee code you select will cause unique IDs to appear for the matching rows in the index, and a simple INDEX/MATCH formula brings them over starting at 1 and up to the MAX index value.
    Thanks a ton!!

    It works perfectely fine..

    Is it possible to put a password to see any data i.e. if any employee want to see his data then he need to enter his assign password.

    If yes then can change password option be given and changed password would be saved in a different (hidden) sheet.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #8

    Mar 4, 2009, 12:17 AM

    No, rather than go through all that, just create your separate "Front sheet only" version for each employee. Put their employee ID in the key cell, then pwd protect the sheet completely, no changes are possible.

    Save it with their info showing and it is drawing from your separate DETAIL sheet. Give them that personalized view only sheet.

    Now anytime they open it, all they can do is read it. The data updates when they open it, and that's it. No one can see anyone else's data without going and opening their own book that you gave just to them.

    Much simpler.
    jamesrrdaniel's Avatar
    jamesrrdaniel Posts: 1, Reputation: 1
    New Member
     
    #9

    Feb 28, 2010, 03:19 PM
    JBeaucaire:

    I know the posts is a year old, but I've been trying to do almost same thing as original poster and been studying the excel files that have been put out.

    Except, now that I try to change the formulas to the way I need it, I have ran into some problems.

    the formulas in p worksheet has { and }
    like: {=IF(ROW()-24>Detail!$B$2,"",INDEX(Detail!B$1:B$1000,SMALL(IF (Detail!$A$1:$A$1000=P!$C$7,ROW($A$1:$A$1000),""), ROW()-24)))}

    In the same worksheet, if I try to mess around with the formula, excel automatically deletes the { and }. And the formula doesn't work. It gives a #VALUE! Error. Although I didn't delete the { } myself.
    Then if I try to enter { and } manually, it won't let me.

    First off, what do { and } do in excel?
    And how can I input it in the excel file and make it work?
    Thank you so much!
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #10

    Feb 28, 2010, 09:03 PM

    Excel adds the braces { } on its own when you enter the formula as an array by pressing CTRL-SHIFT-ENTER instead of just ENTER. This causes the to function evaluate in a completely different way, once for every possible combination of values.

    After you get an array working in the first cell, then you copy it down the column to get the other possible answers in the array.
    sachins19's Avatar
    sachins19 Posts: 11, Reputation: 1
    New Member
     
    #11

    Apr 27, 2010, 05:17 AM
    HI,

    I have been trying hard to read all the posts here and find a solution to my problem but am not able to do so.. So please help.

    I have attached an excel sheet to explain my doubt.
    In the 'summary' sheet I have created a button called Email status. When I click on this button I should be able to pick the rows from sheet B & sheet D where the status is "In Progress" [Column P] and send an email. The output should be diplayed in the body of the message.

    Thanks & Regards,
    Sachin
    Attached Files
  9. File Type: xls Test.xls (76.5 KB, 198 views)

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Auto-Macro in Excel [ 4 Answers ]

Hi, I have a lot of macros built-in Excel, but when I want to update the certain data , I have to run them individually each time. Do you know anyway I can auto-run these macros? Thanks for any help.

Excel macro [ 4 Answers ]

I need to run a macro that opens excel so I can kick off "application.ontime" basically my macro should run without me having to start excel, just have the computer and outlook running. Is that possible?

Recording a macro in Excel [ 2 Answers ]

Need a macro that will select the cell one place to the left, edit the content, hit enter, and then move to cell below where started and repeat to end of column (last cell with a value). Example: 123-456789 is format of cell to be edited - need to remove the hyphen. Someone had created it...

How to Automate a macro in excel [ 4 Answers ]

A program logs files at random in txt. abc_log.txt (example) When new info. Is added to the txt file,manualy activate macro and it does what it suppose to do, all OK there. Is there a way a macro code or excel, or perhaps a BAT program can be made to simply "detect" when new data is added...


View more questions Search