filtering

  • I'm using auto-filter in my applications in order to filter my data(a name for example).my problem is that i can't figure out a way to create a macro that will help me "pick" the name and copy it to another cell.i'm interested in copying just the criteria and not the whole selection.

  • If you want to detect which columns contain a filter and the criteria for the filter, then you can apply the following code (it assumes you have a database with a filter and some criteria in the worksheet 'Sheet1':




    Hans

  • I don't know how to trigger an event by just changing the filter criterion. In case you change something on your sheet or in case you select another cell, you can use the workbook sheetchange and workbook sheetselectionchange events to put the "criterion" in the cell you want. Like this: In the ThisWorkbook module, put the following code:



    Code
    1. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    2. Call UpdateCell15
    3. End Sub
    4. Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    5. Call UpdateCell15
    6. End Sub


    Then add a general module to the VBAproject and add the following code




    It would be better if cell(1, 5) was automatically filled with the name in your selection, but I can't figure out how this can be done.


    Hans